SQLiteDbAccess

Implements an IDbAccess for SQLite.

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

Constructors

SQLiteDbAccess

Default constructor

Signature:
public Void SQLiteDbAccess()

Properties

IsConnectionOpen

Whether the database connection is opened.

Signature:
public Boolean IsConnectionOpen { get; }

IsInTransaction

Whether an opened connection is runing a transaction.

Signature:
public Boolean IsInTransaction { get; }

Password

Password for the database.

Signature:
public String Password { set; }

UserName

User name.

Signature:
public String UserName { set; }
Remarks

This value is not use in SQLite.

Methods

AddParameter

Adds a parameter to command.

Signature:
public Void AddParameter(command, name, type, direction, size, value)
Parameters
Name Type Summary
command IDbCommand An SQLiteCommand.
name String Quoted parameter name.
type DbType Parameter data type.
direction ParameterDirection Direction.
size Int32 Size of the data.
value Object Parameter value.
Exceptions
Type Summary
DataAccessException Thrown when there are an error casting the parameter value.

BeginTransaction

Initiates a database transaction.

Signature:
public IDbTransaction BeginTransaction()
Returns

An object representing the new transaction.

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.

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

A new SQLiteCommand.

Parameters
Name Type Summary
commandType CommandType Type of the command to create.
Exceptions
Type Summary
InvalidOperationException Thrown when commandType is not supported.

Dispose

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

Signature:
public Void Dispose()

ExecuteCommand

Executes the command.

Signature:
public Int32 ExecuteCommand(command, dataTable)
Returns

Quantity of records affected by the command.

Remarks

If the command returns a set of records, the dataTable parameter must contain an initialize DataTable, otherwise it must be null

Parameters
Name Type Summary
command IDbCommand A SQLiteCommand to execute.
dataTable DataTable An initialized DataTable object or null
Exceptions
Type Summary
DataAccessException Thrown when an unindentify error occurs.
OpenConnectionException Thrown when a connection could not be openned.
DuplicatedPrimaryKeyException Thrown when a primary key or unique index constraint fails.
ConstraintViolationException Thrown if a constraint is violated.

ExecuteCommandAsync

Asyncronously executes the command.

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

Quantity of records affected by the command.

Remarks

If the command returns a set of records, the dataTable parameter must contain an initialize DataTable, otherwise it must be null

Parameters
Name Type Summary
command IDbCommand A SQLiteCommand to execute.
dataTable DataTable An initialized DataTable object or null
Exceptions
Type Summary
DataAccessException Thrown when an unindentify error occurs.
OpenConnectionException Thrown when a connection could not be openned.
DuplicatedPrimaryKeyException Thrown when a primary key or unique index constraint fails.
ConstraintViolationException Thrown if a constraint is violated.

ExecuteReader

Executes the command.

Signature:
public IDataReader ExecuteReader(command)
Returns

An IDataReader with command result.

Parameters
Name Type Summary
command IDbCommand A SQLiteCommand to execute.
Exceptions
Type Summary
DataAccessException Thrown when an unindentify error occurs.
InvalidOperationException Thrown when the database connection is not open.

ExecuteReaderAsync

Asyncronously executes the command.

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

An IDataReader with command result.

Parameters
Name Type Summary
command IDbCommand A SQLiteCommand to execute.
Exceptions
Type Summary
DataAccessException Thrown when an unindentify error occurs.
InvalidOperationException Thrown when the database connection is not open.

ExecuteScalar

Executes the command and returns the first field of the first record.

Signature:
public Object ExecuteScalar(command)
Returns

The value of the first field of the first record.

Parameters
Name Type Summary
command IDbCommand An SQLiteCommand to execute.
Exceptions
Type Summary
DataAccessException Thrown when an unindentify error occurs.
OpenConnectionException Thrown when a connection could not be openned.

ExecuteScalarAsync

Asyncronously executes the command and returns the first field of the first record.

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

The value of the first field of the first record.

Parameters
Name Type Summary
command IDbCommand An SQLiteCommand to execute.
Exceptions
Type Summary
DataAccessException Thrown when an unindentify error occurs.
OpenConnectionException Thrown when a connection could not be openned.

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 version of the SQLite NuGet package.

OpenConnection

Opens a connection.

Signature:
public Void OpenConnection()
Exceptions
Type Summary
OpenConnectionException Thrown when the connection could'nt be openned.

OpenConnectionAsync

Opens a connection asyncronously.

Signature:
public Task OpenConnectionAsync()
Exceptions
Type Summary
OpenConnectionException Thrown when the connection could'nt be openned.

RollbackTransaction

Aborts the current transaction.

Signature:
public Void RollbackTransaction()