Table of Contents

Class CommandExtensions

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

Core non-DB-specific extensions for retrieving data from a command using best practices.

public static class CommandExtensions
Inheritance
CommandExtensions
Inherited Members

Methods

AddParameter(IDbCommand, string, DateTime)

Adds a date and time parameter (DateTime) with the given name and value to the command.

AddParameter(IDbCommand, string, DateTimeOffset)

Adds a date and time with offset parameter (DateTimeOffset) with the given name and value to the command.

AddParameter(IDbCommand, string, decimal)

Adds a decimal parameter (Decimal) with the given name and value to the command.

AddParameter(IDbCommand, string, double)

Adds a double-precision floating point parameter (Double) with the given name and value to the command.

AddParameter(IDbCommand, string, Guid)

Adds a GUID parameter (Guid) with the given name and value to the command.

AddParameter(IDbCommand, string, short)

Adds a 16-bit integer parameter (Int16) with the given name and value to the command.

AddParameter(IDbCommand, string, int)

Adds a 32-bit integer parameter (Int32) with the given name and value to the command.

AddParameter(IDbCommand, string, long)

Adds a 64-bit integer parameter (Int64) with the given name and value to the command.

AddParameter(IDbCommand, string, object?)

Adds a parameter with the given name and value to the command, leaving the provider to infer the database type from the value.

AddParameter(IDbCommand, string, object?, DbType, ParameterDirection)

Adds a typed parameter with the given name, value, and direction to the command.

AddParameter(IDbCommand, string, string?)

Adds a string parameter (String) with the given name and value to the command.

AddParameterType(IDbCommand, string?, DbType, ParameterDirection)

Adds a parameter of the given type and direction to the command without assigning a value.

AddReturnParameter(IDbCommand, DbType, string?)

Adds a typed return-value parameter to the command.

AddReturnParameter(IDbCommand, string?)

Adds a return-value parameter to the command, leaving the provider to determine its type.

ExecuteReader(IDbCommand, Action<IDataReader>, CommandBehavior)

Executes a reader on a command with a handler function.

ExecuteReaderAsync(DbCommand, Action<DbDataReader>, CommandBehavior, CancellationToken)

Asynchronously executes a reader on a command with a handler function.

ExecuteReaderAsync(DbCommand, Func<DbDataReader, ValueTask>, CommandBehavior, CancellationToken)

Asynchronously executes a reader on a command with a handler function.

ExecuteReaderAsync(IDbCommand, CommandBehavior, CancellationToken)

If the command is derived from DbCommand, this will call ExecuteReaderAsync(CommandBehavior, CancellationToken); otherwise it will call ExecuteReader(CommandBehavior).

ExecuteReaderAsync(IDbCommand, Func<IDataReader, ValueTask>, CommandBehavior, CancellationToken)

Asynchronously executes a reader on a command with a handler function.

ExecuteReaderAsync<T>(DbCommand, Func<DbDataReader, ValueTask<T>>, CommandBehavior, CancellationToken)

Asynchronously executes a reader on a command with a transform function.

ExecuteReaderAsync<T>(DbCommand, Func<DbDataReader, T>, CommandBehavior, CancellationToken)

Asynchronously executes a reader on a command with a transform function.

ExecuteReaderAsync<T>(IDbCommand, Func<IDataReader, ValueTask<T>>, CommandBehavior, CancellationToken)

Asynchronously executes a reader on a command with a transform function.

ExecuteReader<T>(IDbCommand, Func<IDataReader, T>, CommandBehavior)

Executes a reader on a command with a transform function.

FirstOrDefault<T>(IDbCommand, Func<IDataRecord, T>, CommandBehavior)

Iterates an IDataReader and returns the first result through a transform function.

FirstOrdinalResults(IDbCommand, CommandBehavior)

Reads the first column from every record.

FirstOrdinalResultsAsync(DbCommand, CommandBehavior, bool, CancellationToken)

Reads the first column from every record.

FirstOrdinalResultsAsync<T0>(DbCommand, CommandBehavior, bool, CancellationToken)

Reads the first column from every record.

FirstOrdinalResults<T0>(DbCommand, CommandBehavior)

Reads the first column from every record.

FirstOrdinalResults<T0>(IDbCommand, CommandBehavior)

Reads the first column from every record.

First<T>(IDbCommand, Func<IDataRecord, T>, CommandBehavior)

Iterates an IDataReader and returns the first result through a transform function.

ForEachAsync(DbCommand, Action<IDataRecord>, bool, CancellationToken)

Asynchronously iterates all records from an IDataReader.

ForEachAsync(DbCommand, Action<IDataRecord>, CommandBehavior, bool, CancellationToken)

Asynchronously iterates all records from an IDataReader.

ForEachAsync(DbCommand, Func<IDataRecord, ValueTask>, bool, CancellationToken)

Asynchronously iterates all records from an IDataReader.

ForEachAsync(DbCommand, Func<IDataRecord, ValueTask>, CommandBehavior, bool, CancellationToken)

Asynchronously iterates all records from an IDataReader.

IterateReader(IDbCommand, Action<IDataRecord>, CommandBehavior)

Iterates an IDataReader on a command with a handler function.

IterateReader(IDbCommand, CommandBehavior, Action<IDataRecord>)

Iterates an IDataReader on a command with a handler function.

IterateReaderWhile(IDbCommand, Func<IDataRecord, bool>, CommandBehavior)

Iterates an IDataReader on a command while the predicate returns true.

IterateReaderWhileAsync(DbCommand, Func<IDataRecord, ValueTask<bool>>, CommandBehavior, bool, CancellationToken)

Asynchronously iterates an IDataReader on a command while the predicate returns true.

IterateReader<TEntity, TResult>(IDbCommand, CommandBehavior, Func<IDataRecord, TEntity>, Func<IEnumerable<TEntity>, TResult>)

Executes a reader on a command with a transform function.

IterateReader<TEntity, TResult>(IDbCommand, Func<IDataRecord, TEntity>, Func<IEnumerable<TEntity>, TResult>, CommandBehavior)

Executes a reader on a command with a transform function.

SingleOrDefault<T>(IDbCommand, Func<IDataRecord, T>, CommandBehavior)

Iterates an IDataReader and returns the first result through a transform function.

Single<T>(IDbCommand, Func<IDataRecord, T>, CommandBehavior)

Iterates an IDataReader and returns the first result through a transform function.

SkipThenTake<T>(IDbCommand, int, int, Func<IDataRecord, T>, CommandBehavior)

Iterates an IDataReader and skips by the skip parameter returns the maximum remaining defined by the take parameter.

Skip<T>(IDbCommand, int, Func<IDataRecord, T>, CommandBehavior)

Iterates an IDataReader and skips the first number of results defined by the count.

Take<T>(IDbCommand, int, Func<IDataRecord, T>, CommandBehavior)

Iterates an IDataReader and returns the first number of results defined by the count.

ToArray<T>(IDbCommand, CommandBehavior, Func<IDataRecord, T>)

Iterates all records using an IDataReader and returns the desired results as an array.

ToArray<T>(IDbCommand, Func<IDataRecord, T>, CommandBehavior)

Iterates all records using an IDataReader and returns the desired results as an array.

ToDataTable(IDbCommand, CommandBehavior)

Loads all data from a command through an IDataReader into a DataTable.

ToDataTables(IDbCommand, CommandBehavior)

Loads all data from a command through an IDataReader into a DataTables. Calls .NextResult() to check for more results.

ToImmutableArray<T>(IDbCommand, CommandBehavior, Func<IDataRecord, T>)

Iterates all records using an IDataReader and returns the desired results as an array.

ToImmutableArray<T>(IDbCommand, Func<IDataRecord, T>, CommandBehavior)

Iterates all records using an IDataReader and returns the desired results as an array.

ToListAsync<T>(DbCommand, CommandBehavior, Func<IDataRecord, ValueTask<T>>, CancellationToken)

Asynchronously iterates all records using an IDataReader and returns the desired results as a list.

ToListAsync<T>(DbCommand, CommandBehavior, Func<IDataRecord, T>, bool, CancellationToken)

Asynchronously iterates all records using an IDataReader and returns the desired results as a list.

ToListAsync<T>(DbCommand, CommandBehavior, Func<IDataRecord, T>, CancellationToken)

Asynchronously iterates all records using an IDataReader and returns the desired results as a list.

ToListAsync<T>(DbCommand, Func<IDataRecord, ValueTask<T>>, CommandBehavior, CancellationToken)

Asynchronously iterates all records using an IDataReader and returns the desired results as a list.

ToListAsync<T>(DbCommand, Func<IDataRecord, T>, CommandBehavior, bool, CancellationToken)

Asynchronously iterates all records using an IDataReader and returns the desired results as a list.

ToList<T>(IDbCommand, CommandBehavior, Func<IDataRecord, T>)

Iterates all records using an IDataReader and returns the desired results as a list.

ToList<T>(IDbCommand, Func<IDataRecord, T>, CommandBehavior)

Iterates all records using an IDataReader and returns the desired results as a list.