Interface IDatabaseAdapter

Namespace
RentADeveloper.DbConnectionPlus.DatabaseAdapters
Assembly
RentADeveloper.DbConnectionPlus.dll

Represents an adapter that adapts DbConnectionPlus to a specific database system.

public interface IDatabaseAdapter

Properties

EntityManipulator

The entity manipulator for the database system this adapter supports.

IEntityManipulator EntityManipulator { get; }

Property Value

IEntityManipulator

TemporaryTableBuilder

The temporary table builder for the database system this adapter supports.

ITemporaryTableBuilder TemporaryTableBuilder { get; }

Property Value

ITemporaryTableBuilder

Methods

BindParameterValue(DbParameter, object?)

Binds value to parameter.

If value is an Enum value, it is serialized according to the setting EnumSerializationMode before being assigned to the parameter.

void BindParameterValue(DbParameter parameter, object? value)

Parameters

parameter DbParameter

The parameter to bind value to.

value object

The value to bind to parameter.

Exceptions

ArgumentNullException

parameter is null.

FormatParameterName(string)

Returns parameterName with the appropriate prefix (e.g. "@" for SQL Server or ":" for Oracle) for use in SQL statements.

string FormatParameterName(string parameterName)

Parameters

parameterName string

The parameter name to format.

Returns

string

parameterName formatted with the appropriate prefix, suitable for inclusion in SQL statements.

GetDataType(Type, EnumSerializationMode)

Gets the corresponding database specific data type for the type type.

string GetDataType(Type type, EnumSerializationMode enumSerializationMode)

Parameters

type Type

The type to get the database specific data type for.

enumSerializationMode EnumSerializationMode

The mode to use to serialize Enum values.

Returns

string

The corresponding database specific data type for the type type.

Exceptions

ArgumentNullException

type is null.

ArgumentOutOfRangeException
  • enumSerializationMode is not a valid EnumSerializationMode value.
  • The type type could not be mapped to a database specific data type.

QuoteIdentifier(string)

Returns identifier properly quoted for use in SQL statements.

string QuoteIdentifier(string identifier)

Parameters

identifier string

The identifier to be quoted.

Returns

string

A string containing the quoted version of identifier, suitable for use in SQL statements.

QuoteTemporaryTableName(string, DbConnection)

Returns the specified name of a temporary table properly quoted for use in SQL statements.

string QuoteTemporaryTableName(string tableName, DbConnection connection)

Parameters

tableName string

The temporary table name to quote.

connection DbConnection

The database connection to use for quoting.

Returns

string

A string containing the quoted version of tableName, suitable for use in SQL statements.

SupportsTemporaryTables(DbConnection)

Determines whether the database system this adapter supports has support for (local/session scoped) temporary tables.

bool SupportsTemporaryTables(DbConnection connection)

Parameters

connection DbConnection

The database connection to use to check for the support.

Returns

bool

true if the database system supports temporary tables; otherwise, false.

Remarks

A database adapter returning true for this method must implement an ITemporaryTableBuilder and provide an instance of it via the TemporaryTableBuilder property.

If a database adapter returns false for this method, it must throw a NotSupportedException from the TemporaryTableBuilder property.

WasSqlStatementCancelledByCancellationToken(Exception, CancellationToken)

Determines whether exception was thrown because an SQL statement was cancelled via cancellationToken.

bool WasSqlStatementCancelledByCancellationToken(Exception exception, CancellationToken cancellationToken)

Parameters

exception Exception

The exception to inspect.

cancellationToken CancellationToken

The token via the SQL statement may have been cancelled.

Returns

bool

true if exception was thrown because an SQL statement was cancelled via cancellationToken; otherwise, false.

Exceptions

ArgumentNullException

exception is null.