DbAccess

Abstract base class for implementator of IDbAccess

Namespace:
KpokPatagon.Data
Type:
Class
Public:
Yes
Protected:
No
Sealed:
No
Abstract:
Yes
Implements:
KpokPatagon.Data.IDbAccess, System.IDisposable

Events

Type Name Summary
InfoMessageEventHandler InfoMessage Occurs when the database engine returns a warning of informational message.

Properties

ConnectionString

Gets or sets the connection string used to connect to the database.

Signature:
public String ConnectionString { get; set; }

DefaultSchema

Default schema for database objects.

Signature:
public String DefaultSchema { get; set; }

IsConnectionOpen

Indicates whether the connection is opened.

Signature:
public Boolean IsConnectionOpen { get; }

IsInTransaction

Indicates whether an opened connection is in a transaction.

Signature:
public Boolean IsInTransaction { get; }

Logger

A logger categorized for the database API interface.

Signature:
public ILogger<IDbAccess> Logger { get; set; }

Name

Gets or sets the name of the connection.

Signature:
public String Name { get; set; }

Retries

Specify how many times a failed operation will be retried.

Signature:
public Int32 Retries { get; set; }

Methods

AddParameter

Adds a new parameter to the command passed as parameter

Signature:
public Void AddParameter(command, name, type, direction, value)
Parameters
Name Type Summary
command IDbCommand The command where the parameter will be added
name String The quoted parameter name
type DbType The parameter data type
direction ParameterDirection The parameter direction
value Object The value of the parameter

AddParameter

Adds a new parameter to the command passed as parameter

Signature:
public Void AddParameter(command, name, type, direction, size, value)
Parameters
Name Type Summary
command IDbCommand The command where the parameter will be added
name String The quoted parameter name
type DbType The parameter data type
direction ParameterDirection The parameter direction
size Int32 The size of the data in the valueparameter
value Object The value of the parameter

BeginTransaction

Initiates a database transaction

Signature:
public Void BeginTransaction()
Returns

An object representing the new transaction

BeginTransaction

Initiates a database transaction with the specified isolation level

Signature:
public Void BeginTransaction(iso)
Returns

Ann object representing the new transaction

Parameters
Name Type Summary
iso IsolationLevel Isolation level for the transaction

CloseConnection

Closes the database connection if it is opened

Signature:
public Void CloseConnection()

CommitTransaction

Commits the running database transaction

Signature:
public Void CommitTransaction()

CreateCommand

Creates a new database command

Signature:
public IDbCommand CreateCommand(commandType)
Returns

An object representing the newly created command

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

Dispose

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

Signature:
public Void Dispose()

ExecuteNonQuery

Executes the specified command against the database.

Signature:
public Int32 ExecuteNonQuery(command)
Returns

Quantity of records affected by the command.

Parameters
Name Type Summary
command IDbCommand Command to execute

ExecuteNonQueryAsync

Executes the specified command asyncronously against the database.

Signature:
public Task ExecuteNonQueryAsync(command)
Returns

Quantity of records affected by the command.

Parameters
Name Type Summary
command IDbCommand Command to execute

ExecuteReader

Executes the specified command against the database and returns a IDataReader.

Signature:
public IDataReader ExecuteReader(command)
Returns

A read only forward only IDataReader with the database data.

Parameters
Name Type Summary
command IDbCommand Command to execute.

ExecuteReaderAsync

Executes the specified command against the database asyncronously and returns an IDataReader.

Signature:
public Task ExecuteReaderAsync(command)
Parameters
Name Type Summary
command IDbCommand Command to execute.

ExecuteScalar

Executes the specified command against the database and returns the first fields of the first record retrieved

Signature:
public Object ExecuteScalar(command)
Returns

Value of the first field of the first record

Parameters
Name Type Summary
command IDbCommand Command to excecute

ExecuteScalarAsync

Executes the specified command againts the database asyncronously and returns the first field of the first record retrieved.

Signature:
public Task ExecuteScalarAsync(command)
Parameters
Name Type Summary
command IDbCommand Command to execute.

GetDatabaseEngine

Gets the database engine for this API.

Signature:
public DatabaseEngine GetDatabaseEngine()

GetServerVersion

Gets the server version.

Signature:
public String GetServerVersion()
Returns

The server version.

OnInfoMessage

Helper to raise the InfoMessage event.

Signature:
protected Void OnInfoMessage(sender, e)
Parameters
Name Type Summary
sender Object
e InfoMessageEventArgs

OpenConnection

Opens a connection with the database server

Signature:
public Void OpenConnection()

OpenConnectionAsync

Opens a connection with the database server asyncronously.

Signature:
public Task OpenConnectionAsync()

RollbackTransaction

Aborts the current transaction

Signature:
public Void RollbackTransaction()