Table of Contents

Method ExecuteReaderAsync

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

ExecuteReaderAsync(IDbCommand, CancellationToken)

Asynchronously executes a reader, calling ExecuteReaderAsync(CommandBehavior, CancellationToken) if the command is derived from DbCommand; otherwise it calls ExecuteReader(CommandBehavior).

public static ValueTask<IDataReader> ExecuteReaderAsync(this IDbCommand command, CancellationToken cancellationToken = default)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask<IDataReader>

A task that represents the asynchronous operation. Its result is the reader.

Remarks

This member does not open the connection: it must already be open, and the caller owns and disposes the reader.

Exceptions

ArgumentNullException

command is null.

ExecuteReaderAsync(IDbCommand, CommandBehavior, CancellationToken)

Asynchronously executes a reader, calling ExecuteReaderAsync(CommandBehavior, CancellationToken) if the command is derived from DbCommand; otherwise it calls ExecuteReader(CommandBehavior).

public static ValueTask<IDataReader> ExecuteReaderAsync(this IDbCommand command, CommandBehavior behavior, CancellationToken cancellationToken = default)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

behavior CommandBehavior

The behavior to use with the data reader. The default is Default.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask<IDataReader>

A task that represents the asynchronous operation. Its result is the reader.

Remarks

This member does not open the connection: it must already be open, and the caller owns and disposes the reader.

Exceptions

ArgumentNullException

command is null.

ExecuteReaderAsync(DbCommand, Action<DbDataReader>, CancellationToken)

Asynchronously executes a reader and passes it to a handler.

public static ValueTask ExecuteReaderAsync(this DbCommand command, Action<DbDataReader> handler, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

handler Action<DbDataReader>

The function that receives the reader.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask

A task that represents the asynchronous operation.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or handler is null.

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

Asynchronously executes a reader and passes it to a handler.

public static ValueTask ExecuteReaderAsync(this DbCommand command, Action<DbDataReader> handler, CommandBehavior behavior, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

handler Action<DbDataReader>

The function that receives the reader.

behavior CommandBehavior

The behavior to use with the data reader. The default is Default.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask

A task that represents the asynchronous operation.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or handler is null.

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

Asynchronously executes a reader and passes it to an asynchronous handler.

public static ValueTask ExecuteReaderAsync(this IDbCommand command, Func<IDataReader, ValueTask> handler, CancellationToken cancellationToken = default)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

handler Func<IDataReader, ValueTask>

The function that receives the reader.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask

A task that represents the asynchronous operation.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or handler is null.

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

Asynchronously executes a reader and passes it to an asynchronous handler.

public static ValueTask ExecuteReaderAsync(this IDbCommand command, Func<IDataReader, ValueTask> handler, CommandBehavior behavior, CancellationToken cancellationToken = default)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

handler Func<IDataReader, ValueTask>

The function that receives the reader.

behavior CommandBehavior

The behavior to use with the data reader. The default is Default.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask

A task that represents the asynchronous operation.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or handler is null.

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

Asynchronously executes a reader and passes it to an asynchronous handler.

public static ValueTask ExecuteReaderAsync(this DbCommand command, Func<DbDataReader, ValueTask> handler, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

handler Func<DbDataReader, ValueTask>

The function that receives the reader.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask

A task that represents the asynchronous operation.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or handler is null.

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

Asynchronously executes a reader and passes it to an asynchronous handler.

public static ValueTask ExecuteReaderAsync(this DbCommand command, Func<DbDataReader, ValueTask> handler, CommandBehavior behavior, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

handler Func<DbDataReader, ValueTask>

The function that receives the reader.

behavior CommandBehavior

The behavior to use with the data reader. The default is Default.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask

A task that represents the asynchronous operation.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or handler is null.

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

Asynchronously executes a reader and returns the result of a transform function applied to it.

public static ValueTask<T> ExecuteReaderAsync<T>(this DbCommand command, Func<DbDataReader, T> transform, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

transform Func<DbDataReader, T>

The function that receives the reader and returns the result.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask<T>

A task that represents the asynchronous operation. Its result is the result of the transform.

Type Parameters

T

The return type of the transform function.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or transform is null.

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

Asynchronously executes a reader and returns the result of a transform function applied to it.

public static ValueTask<T> ExecuteReaderAsync<T>(this DbCommand command, Func<DbDataReader, T> transform, CommandBehavior behavior, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

transform Func<DbDataReader, T>

The function that receives the reader and returns the result.

behavior CommandBehavior

The behavior to use with the data reader. The default is Default.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask<T>

A task that represents the asynchronous operation. Its result is the result of the transform.

Type Parameters

T

The return type of the transform function.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or transform is null.

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

Asynchronously executes a reader and returns the result of a transform function applied to it.

public static ValueTask<T> ExecuteReaderAsync<T>(this IDbCommand command, Func<IDataReader, ValueTask<T>> transform, CancellationToken cancellationToken = default)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

transform Func<IDataReader, ValueTask<T>>

The function that receives the reader and returns the result.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask<T>

A task that represents the asynchronous operation. Its result is the result of the transform.

Type Parameters

T

The return type of the transform function.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or transform is null.

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

Asynchronously executes a reader and returns the result of a transform function applied to it.

public static ValueTask<T> ExecuteReaderAsync<T>(this IDbCommand command, Func<IDataReader, ValueTask<T>> transform, CommandBehavior behavior, CancellationToken cancellationToken = default)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

transform Func<IDataReader, ValueTask<T>>

The function that receives the reader and returns the result.

behavior CommandBehavior

The behavior to use with the data reader. The default is Default.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask<T>

A task that represents the asynchronous operation. Its result is the result of the transform.

Type Parameters

T

The return type of the transform function.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or transform is null.

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

Asynchronously executes a reader and returns the result of a transform function applied to it.

public static ValueTask<T> ExecuteReaderAsync<T>(this DbCommand command, Func<DbDataReader, ValueTask<T>> transform, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

transform Func<DbDataReader, ValueTask<T>>

The function that receives the reader and returns the result.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask<T>

A task that represents the asynchronous operation. Its result is the result of the transform.

Type Parameters

T

The return type of the transform function.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or transform is null.

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

Asynchronously executes a reader and returns the result of a transform function applied to it.

public static ValueTask<T> ExecuteReaderAsync<T>(this DbCommand command, Func<DbDataReader, ValueTask<T>> transform, CommandBehavior behavior, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

transform Func<DbDataReader, ValueTask<T>>

The function that receives the reader and returns the result.

behavior CommandBehavior

The behavior to use with the data reader. The default is Default.

cancellationToken CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

ValueTask<T>

A task that represents the asynchronous operation. Its result is the result of the transform.

Type Parameters

T

The return type of the transform function.

Remarks

The connection is opened if it is closed, and closed again when the call finishes; a connection that was already open is left as it was. A connection this call opened is also closed, never disposed, when the reader cannot be created.

Exceptions

ArgumentNullException

command or transform is null.