MySqlDbAccess

Implements an IDbAccess for MySql.

Namespace:
Inetdev.Data.MySql
Type:
Class
Public:
Yes
Protected:
No
Sealed:
No
Abstract:
No
Inherits from:
Inetdev.Data.AbstractDbAccess

Constructors

MySqlDbAccess

Default constructor

Signature:
public Void MySqlDbAccess()

Properties

CertificateFile

Path the a *.pfx certificate file for encrypted connections.

Signature:
public String CertificateFile { get; set; }

CertificatePassword

Password for the certificate.

Signature:
public String CertificatePassword { get; set; }

Encrypt

Whether the connection is encrypted.

Signature:
public Nullable<Boolean> Encrypt { get; set; }

IsConnectionOpen

Get whether the database connection is opened.

Signature:
public Boolean IsConnectionOpen { get; }

IsInTransaction

Get whether an opened connection is running a transaction.

Signature:
public Boolean IsInTransaction { get; }

Password

Password of the user used to connect to the database.

Signature:
public String Password { set; }

SslMode

SSL Model.

Signature:
public String SslMode { get; set; }

UserName

User name to connecto to the database.

Signature:
public String UserName { set; }

Methods

AddParameter

Adds a parameter to the command.

Signature:
public Void AddParameter(command, name, type, direction, size, value)
Parameters
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.
Exceptions
Type Summary
DataAccessException Thrown when the data does not match the parameter type.

BeginTransaction

Initiates a database transaction.

Signature:
public IDbTransaction BeginTransaction()
Returns

An object representing the new transaction.

Exceptions
Type Summary
OpenedConnectionRequiredException Thrown when the connection is closed.

BeginTransaction

Initiates a database transaction with the specified isolation level.

Signature:
public IDbTransaction BeginTransaction(iso)
Returns

An object representing the new transaction.

Parameters
Name Type Summary
iso IsolationLevel Isolation level for the transaction.
Exceptions
Type Summary
OpenedConnectionRequiredException Thrown when the connection is closed.

CloseConnection

Closes the database connection if it is openned.

Signature:
public Void CloseConnection()

CommitTransaction

Commits the current transaction.

Signature:
public Void CommitTransaction()

CreateCommand

Creates an IDbCommand for MySql for the specified commandType.

Signature:
public IDbCommand CreateCommand(commandType)
Returns

An IDbCommand.

Parameters
Name Type Summary
commandType CommandType Type of the command to create.

Dispose

Performs tasks associated with freeing, releasing, or reseting unmaneged resources.

Signature:
public Void Dispose()

ExecuteCommand

Execute the command against the database.

Signature:
public Int32 ExecuteCommand(command, dataTable)
Returns

Amount of records affected by the command.

Remarks

If the command returns a set of records the dataTable must point to an initialized DataTable otherwise it must be null.

Parameters
Name Type Summary
command IDbCommand A MySqlCommand to execute.
dataTable DataTable A DataTable where SELECT results are returned.
Exceptions
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.

ExecuteCommandAsync

Asyncronously execute the command against the database.

Signature:
public Task<Int32> ExecuteCommandAsync(command, dataTable)
Returns

Amount of records affected by the command.

Remarks

If the command returns a set of records the dataTable must point to an initialized DataTable otherwise it must be null.

Parameters
Name Type Summary
command IDbCommand A MySqlCommand to execute.
dataTable DataTable A DataTable where SELECT results are returned.
Exceptions
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.

ExecuteReader

Executes the command against the database and returns an IDataReader with the result.

Signature:
public IDataReader ExecuteReader(command)
Returns

An IDataReader with the results of the command.

Parameters
Name Type Summary
command IDbCommand A MySqlCommand to execute.
Exceptions
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.

ExecuteReaderAsync

Asyncronously executes the command against the database and returns an IDataReader with the result.

Signature:
public Task<IDataReader> ExecuteReaderAsync(command)
Returns

An IDataReader with the results of the command.

Parameters
Name Type Summary
command IDbCommand A MySqlCommand to execute.
Exceptions
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.

ExecuteScalar

Ejecutes the command against the database and returns the first field of the first record returned.

Signature:
public Object ExecuteScalar(command)
Returns

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.

Parameters
Name Type Summary
command IDbCommand A MySqlCommand to execute.
Exceptions
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.

ExecuteScalarAsync

Ejecutes the command against the database and returns the first field of the first record returned.

Signature:
public Task<Object> ExecuteScalarAsync(command)
Returns

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.

Parameters
Name Type Summary
command IDbCommand A MySqlCommand to execute.
Exceptions
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.

GetSchema

Ejecutes the underlaying connection GetSchema() method.

Signature:
public DataTable GetSchema()
Returns

A DataTable as obtained from the GetSchema() method.

Exceptions
Type Summary
DataAccessException Thrown when an unindentify error occurs.

GetSchema

Ejecutes the underlaying connection GetSchema() method.

Signature:
public DataTable GetSchema(collectionName)
Returns

A DataTable as obtained from the GetSchema() method.

Parameters
Name Type Summary
collectionName String The name of the collection to retrieve.
Exceptions
Type Summary
DataAccessException Thrown when an unindentify error occurs.

GetSchema

Ejecutes the underlaying connection GetSchema() method.

Signature:
public DataTable GetSchema(collectionName, restrictionValues)
Returns

A DataTable as obtained from the GetSchema() method.

Parameters
Name Type Summary
collectionName String The name of the collection to retrieve.
restrictionValues String[] A set of restriction values.
Exceptions
Type Summary
DataAccessException Thrown when an unindentify error occurs.

GetServerVersion

Gets the server version.

Signature:
public String GetServerVersion()
Returns

The server version.

Exceptions
Type Summary
SchemaManipulationException Thrown when there is an error accesing schema data.

OpenConnection

Opens a connection to the database server.

Signature:
public Void OpenConnection()
Exceptions
Type Summary
OpenConnectionException Thrown when an unindentify error occurs.
ServerUnavailableException Thrown when the database server is not available.
InvalidCredentialsException Thrown when credentials are invalid.

OpenConnectionAsync

Asyncronously opens a connection to the database server.

Signature:
public Task OpenConnectionAsync()
Exceptions
Type Summary
OpenConnectionException Thrown when an unindentify error occurs.
ServerUnavailableException Thrown when the database server is not available.
InvalidCredentialsException Thrown when credentials are invalid.

RollbackTransaction

Rollbacks the current transaction.

Signature:
public Void RollbackTransaction()