Table of Contents

Class ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis>

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

Base class for developing expressive commands. Includes methods for use with IDbConnection and IDbCommand types.

public abstract class ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis> : IExecuteCommand<TCommand>, IExecuteCommand, IExecuteReader<TReader>, IExecuteReader where TConnection : class, IDbConnection where TCommand : class, IDbCommand where TReader : class, IDataReader where TDbType : struct where TThis : ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis>

Type Parameters

TConnection

The type of the connection to be used.

TCommand

The type of the commands generated by the connection.

TReader

The type of reader created by the command.

TDbType

The DB type enum to use for parameters.

TThis

The type of this class in order to facilitate proper expressive notation.

Inheritance
ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis>
Implements
IExecuteCommand<TCommand>
Derived
Inherited Members
Extension Methods

Constructors

ExpressiveCommandBase(IDbConnectionFactory<TConnection>, CommandType, string, IEnumerable<Param>?)

Constructs a ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis>.

ExpressiveCommandBase(IDbConnectionPool<TConnection>, CommandType, string, IEnumerable<Param>?)

Constructs a ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis>.

ExpressiveCommandBase(IDbTransaction, CommandType, string, IEnumerable<Param>?)

Constructs a ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis>.

ExpressiveCommandBase(Func<TConnection>, CommandType, string, IEnumerable<Param>?)

Constructs a ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis>.

ExpressiveCommandBase(TConnection, CommandType, string, IEnumerable<Param>?)

Constructs a ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis>.

ExpressiveCommandBase(TConnection, IDbTransaction?, CommandType, string, IEnumerable<Param>?)

Constructs a ExpressiveCommandBase<TConnection, TCommand, TReader, TDbType, TThis>.

Properties

CancellationToken

The optional cancellation token to use with supported methods.

Command

The command text or procedure name to use.

ConnectionProvider

The connection provider to used to acquire connections.

Params

The list of params to apply to the command before execution.

Timeout

The command timeout value.

Transaction

The transaction to execute commands on if not using a connection factory.

Type

The command type.

Methods

AddParam(Param)

Shortcut to add a parameter to the params list.

AddParam(string, ParameterDirection)

Adds a parameter to the params list.

AddParam(string, int, TDbType?, ParameterDirection)

Adds a parameter to the params list.

AddParam(string, long, TDbType?, ParameterDirection)

Adds a parameter to the params list.

AddParam(string, object?, ParameterDirection)

Adds a parameter to the params list.

AddParam(string, object, TDbType, ParameterDirection)

Adds a parameter to the params list.

AddParam(string, string?, TDbType?, ParameterDirection)

Adds a parameter to the params list.

AddParam(string, TDbType, ParameterDirection)

Adds a parameter to the params list.

AddParamIf(bool, string, ParameterDirection)

Conditionally adds a parameter to the params list.

AddParamIf(bool, string, int, TDbType?, ParameterDirection)

Conditionally adds a parameter to the params list.

AddParamIf(bool, string, long, TDbType?, ParameterDirection)

Conditionally adds a parameter to the params list.

AddParamIf(bool, string, object?, ParameterDirection)

Conditionally adds a parameter to the params list.

AddParamIf(bool, string, object, TDbType, ParameterDirection)

Conditionally adds a parameter to the params list.

AddParamIf(bool, string, TDbType, ParameterDirection)

Conditionally adds a parameter to the params list.

AddParamIf<T>(bool, string, T?, ParameterDirection)

Conditionally adds a parameter to the params list.

AddParamIf<T>(bool, string, T?, TDbType?, ParameterDirection)

Conditionally adds a parameter to the params list.

AddParam<T>(string, T?, TDbType?, ParameterDirection)

Adds a parameter to the params list.

AddParams(TCommand)

Handles adding the list of parameters to a new command.

AddReturnParam(string)

Adds a return parameter to the params list.

AddReturnParam(string, TDbType)

Adds a return parameter to the params list.

Concat<T>(T, ICollection<T>)

Utility for simplifying param concatenation.

EnsureReaderType<TActual>(TActual)

Validates and properly acquires the expected type of the reader.

Execute(Action<TCommand>)

Creates a command of type TCommand and passes it to action.

ExecuteAsync(Func<TCommand, ValueTask>)

Asynchronously creates a command of type TCommand and passes it to handler.

ExecuteAsync<T>(Func<TCommand, ValueTask<T>>)

Asynchronously creates a command of type TCommand and passes it to transform, returning its result.

ExecuteNonQuery()

Calls ExecuteNonQuery on the underlying command.

ExecuteReader(Action<TReader>, CommandBehavior)

Executes a reader on a command with a handler function.

ExecuteReaderAsync(Action<TReader>, CommandBehavior)
ExecuteReaderAsync(Func<TReader, ValueTask>, CommandBehavior)

Executes a reader on a command with a handler function.

ExecuteReaderAsync<T>(Func<TReader, ValueTask<T>>, CommandBehavior)

Executes a reader on a command with a handler function.

ExecuteReaderAsync<T>(Func<TReader, T>, CommandBehavior)
ExecuteReaderAsync<TState, TResult>(TState, Func<IDataReader, TState, ValueTask<TResult>>, CommandBehavior)

Executes a reader on a command, passing state to transform. Pass a static lambda and the state it needs to avoid allocating a closure per call.

ExecuteReader<T>(Func<TReader, T>, CommandBehavior)

Executes a reader on a command with a transform function.

ExecuteReader<TState, TResult>(TState, Func<IDataReader, TState, TResult>, CommandBehavior)

Executes a reader on a command, passing state to transform. Pass a static lambda and the state it needs to avoid allocating a closure per call.

ExecuteReturn()

Calls ExecuteNonQuery on the underlying command but sets up a return parameter and returns that value.

ExecuteReturnAsync()

Calls ExecuteNonQueryAsync on the underlying command but sets up a return parameter and returns that value.

ExecuteReturnAsync<T>()

Calls ExecuteNonQueryAsync on the underlying command but sets up a return parameter and returns that value.

ExecuteReturn<T>()

Calls ExecuteNonQuery on the underlying command but sets up a return parameter and returns that value.

ExecuteScalar()

Calls ExecuteScalar on the underlying command.

ExecuteScalar<T>()

Calls ExecuteScalar on the underlying command.

ExecuteScalar<T>(Func<object?, T>)

Calls ExecuteScalar on the underlying command.

Execute<T>(Func<TCommand, T>)

Creates a command of type TCommand and passes it to transform, returning its result.

PrepareCommand(TConnection)

Creates the expected command type from the connection provided.

SetTimeout(ushort)

Sets the timeout value.

UseCancellationToken(CancellationToken)

Sets the cancellation token.