Table of Contents

Class SqlCommandExtensions

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.MSSqlClient.dll

SqlClient extensions for building a command and retrieving data using best practices.

public static class SqlCommandExtensions
Inheritance
SqlCommandExtensions
Inherited Members

Methods

AddParameter(SqlCommand, string, object?, SqlDbType, ParameterDirection)

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

AddParameterType(SqlCommand, string?, SqlDbType, ParameterDirection)

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

AddParameterType(IDbCommand, string, SqlDbType)

Adds an input parameter of the given type to a command that must be a SqlCommand, without assigning a value.

AddReturnParameter(SqlCommand, SqlDbType, string?)

Adds a typed return-value parameter to the command.

ExecuteReader(SqlCommand, Action<SqlDataReader>, CommandBehavior)

Executes the command and passes the SqlDataReader to the handler. The reader is disposed afterwards.

ExecuteReaderAsync(SqlCommand, Action<SqlDataReader>, CommandBehavior, CancellationToken)

Asynchronously executes the command and passes the SqlDataReader to the handler. The reader is disposed afterwards.

ExecuteReaderAsync(SqlCommand, Func<SqlDataReader, ValueTask>, CommandBehavior, CancellationToken)

Asynchronously executes the command and passes the SqlDataReader to the handler. The reader is disposed afterwards.

ExecuteReaderAsync<T>(SqlCommand, Func<SqlDataReader, ValueTask<T>>, CommandBehavior, CancellationToken)

Asynchronously executes the command and passes the SqlDataReader to the transform function, returning its result. The reader is disposed afterwards.

ExecuteReaderAsync<T>(SqlCommand, Func<SqlDataReader, T>, CommandBehavior, CancellationToken)

Asynchronously executes the command and passes the SqlDataReader to the transform function, returning its result. The reader is disposed afterwards.

ExecuteReader<T>(SqlCommand, Func<SqlDataReader, T>, CommandBehavior)

Executes the command and passes the SqlDataReader to the transform function, returning its result. The reader is disposed afterwards.