Implements an IDbAccess for MySql.
Default constructor
public Void MySqlDbAccess()
Path the a *.pfx certificate file for encrypted connections.
public String CertificateFile { get; set; }
Password for the certificate.
public String CertificatePassword { get; set; }
Whether the connection is encrypted.
public Nullable<Boolean> Encrypt { get; set; }
Get whether the database connection is opened.
public Boolean IsConnectionOpen { get; }
Get whether an opened connection is running a transaction.
public Boolean IsInTransaction { get; }
Password of the user used to connect to the database.
public String Password { set; }
SSL Model.
public String SslMode { get; set; }
User name to connecto to the database.
public String UserName { set; }
Adds a parameter to the command.
public Void AddParameter(command, name, type, direction, size, value)
Name | Type | Summary |
---|---|---|
command | IDbCommand | An IDbCommand to which add the parameter. |
name | String | Quoted parameter name. |
type | DbType | Parameter data type. |
direction | ParameterDirection | Parameter direction. |
size | Int32 | Size of the data. |
value | Object | Parameter value. |
Type | Summary |
---|---|
DataAccessException | Thrown when the data does not match the parameter type. |
Initiates a database transaction.
public IDbTransaction BeginTransaction()
An object representing the new transaction.
Type | Summary |
---|---|
OpenedConnectionRequiredException | Thrown when the connection is closed. |
Initiates a database transaction with the specified isolation level.
public IDbTransaction BeginTransaction(iso)
An object representing the new transaction.
Name | Type | Summary |
---|---|---|
iso | IsolationLevel | Isolation level for the transaction. |
Type | Summary |
---|---|
OpenedConnectionRequiredException | Thrown when the connection is closed. |
Closes the database connection if it is openned.
public Void CloseConnection()
Commits the current transaction.
public Void CommitTransaction()
Creates an IDbCommand for MySql for the specified commandType.
public IDbCommand CreateCommand(commandType)
An IDbCommand.
Name | Type | Summary |
---|---|---|
commandType | CommandType | Type of the command to create. |
Performs tasks associated with freeing, releasing, or reseting unmaneged resources.
public Void Dispose()
Execute the command against the database.
public Int32 ExecuteCommand(command, dataTable)
Amount of records affected by the command.
If the command returns a set of records the dataTable must point to an initialized DataTable otherwise it must be null.
Name | Type | Summary |
---|---|---|
command | IDbCommand | A MySqlCommand to execute. |
dataTable | DataTable | A DataTable where SELECT results are returned. |
Type | Summary |
---|---|
DataAccessException | Thrown when an un-identified error occurs. |
OpenConnectionException | Thrown when a connection could not be openned. |
ConstraintViolationException | Thrown when a constaint is violated. |
DuplicatedPrimaryKeyException | Thrown when a primery key or unique index is violated. |
DatabaseObjectNotFoundException | Thrown when a database object, table, view, field, etc. does not exists. |
Asyncronously execute the command against the database.
public Task<Int32> ExecuteCommandAsync(command, dataTable)
Amount of records affected by the command.
If the command returns a set of records the dataTable must point to an initialized DataTable otherwise it must be null.
Name | Type | Summary |
---|---|---|
command | IDbCommand | A MySqlCommand to execute. |
dataTable | DataTable | A DataTable where SELECT results are returned. |
Type | Summary |
---|---|
DataAccessException | Thrown when an un-identified error occurs. |
OpenConnectionException | Thrown when a connection could not be openned. |
ConstraintViolationException | Thrown when a constaint is violated. |
DuplicatedPrimaryKeyException | Thrown when a primery key or unique index is violated. |
DatabaseObjectNotFoundException | Thrown when a database object, table, view, field, etc. does not exists. |
Executes the command against the database and returns an IDataReader with the result.
public IDataReader ExecuteReader(command)
An IDataReader with the results of the command.
Name | Type | Summary |
---|---|---|
command | IDbCommand | A MySqlCommand to execute. |
Type | Summary |
---|---|
DataAccessException | Thrown when an un-identified error occurs. |
InvalidOperationException | Thrown when the connection is not openned. |
DatabaseObjectNotFoundException | Thrown when a database object, table, view, field, etc. does not exists. |
Asyncronously executes the command against the database and returns an IDataReader with the result.
public Task<IDataReader> ExecuteReaderAsync(command)
An IDataReader with the results of the command.
Name | Type | Summary |
---|---|---|
command | IDbCommand | A MySqlCommand to execute. |
Type | Summary |
---|---|
DataAccessException | Thrown when an un-identified error occurs. |
InvalidOperationException | Thrown when the connection is not openned. |
DatabaseObjectNotFoundException | Thrown when a database object, table, view, field, etc. does not exists. |
Ejecutes the command against the database and returns the first field of the first record returned.
public Object ExecuteScalar(command)
Value of the first field of the first record. If the CommandType is a Stored Procedure the value of the parameter with Direction equals to ReturnValue is returned.
Name | Type | Summary |
---|---|---|
command | IDbCommand | A MySqlCommand to execute. |
Type | Summary |
---|---|
DataAccessException | Thrown when an un-indentify error occurs. |
OpenConnectionException | Thrown when a connection could not be openned. |
DatabaseObjectNotFoundException | Thrown when a database object, as a table, view, field, etc., does not exist. |
Ejecutes the command against the database and returns the first field of the first record returned.
public Task<Object> ExecuteScalarAsync(command)
Value of the first field of the first record. If the CommandType is a Stored Procedure the value of the parameter with Direction equals to ReturnValue is returned.
Name | Type | Summary |
---|---|---|
command | IDbCommand | A MySqlCommand to execute. |
Type | Summary |
---|---|
DataAccessException | Thrown when an un-indentify error occurs. |
OpenConnectionException | Thrown when a connection could not be openned. |
DatabaseObjectNotFoundException | Thrown when a database object, as a table, view, field, etc., does not exist. |
Ejecutes the underlaying connection GetSchema() method.
public DataTable GetSchema()
A DataTable as obtained from the GetSchema() method.
Type | Summary |
---|---|
DataAccessException | Thrown when an unindentify error occurs. |
Ejecutes the underlaying connection GetSchema() method.
public DataTable GetSchema(collectionName)
A DataTable as obtained from the GetSchema() method.
Name | Type | Summary |
---|---|---|
collectionName | String | The name of the collection to retrieve. |
Type | Summary |
---|---|
DataAccessException | Thrown when an unindentify error occurs. |
Ejecutes the underlaying connection GetSchema() method.
public DataTable GetSchema(collectionName, restrictionValues)
A DataTable as obtained from the GetSchema() method.
Name | Type | Summary |
---|---|---|
collectionName | String | The name of the collection to retrieve. |
restrictionValues | String[] | A set of restriction values. |
Type | Summary |
---|---|
DataAccessException | Thrown when an unindentify error occurs. |
Gets the server version.
public String GetServerVersion()
The server version.
Type | Summary |
---|---|
SchemaManipulationException | Thrown when there is an error accesing schema data. |
Opens a connection to the database server.
public Void OpenConnection()
Type | Summary |
---|---|
OpenConnectionException | Thrown when an unindentify error occurs. |
ServerUnavailableException | Thrown when the database server is not available. |
InvalidCredentialsException | Thrown when credentials are invalid. |
Asyncronously opens a connection to the database server.
public Task OpenConnectionAsync()
Type | Summary |
---|---|
OpenConnectionException | Thrown when an unindentify error occurs. |
ServerUnavailableException | Thrown when the database server is not available. |
InvalidCredentialsException | Thrown when credentials are invalid. |
Rollbacks the current transaction.
public Void RollbackTransaction()
In this document