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
commandIDbCommandThe IDbCommand to generate a reader from.
cancellationTokenCancellationTokenThe 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
commandis 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
commandIDbCommandThe IDbCommand to generate a reader from.
behaviorCommandBehaviorThe behavior to use with the data reader. The default is Default.
cancellationTokenCancellationTokenThe 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
commandis 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
commandDbCommandThe DbCommand to generate a reader from.
handlerAction<DbDataReader>The function that receives the reader.
cancellationTokenCancellationTokenThe 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
commandorhandleris 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
commandDbCommandThe DbCommand to generate a reader from.
handlerAction<DbDataReader>The function that receives the reader.
behaviorCommandBehaviorThe behavior to use with the data reader. The default is Default.
cancellationTokenCancellationTokenThe 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
commandorhandleris 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
commandIDbCommandThe IDbCommand to generate a reader from.
handlerFunc<IDataReader, ValueTask>The function that receives the reader.
cancellationTokenCancellationTokenThe 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
commandorhandleris 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
commandIDbCommandThe IDbCommand to generate a reader from.
handlerFunc<IDataReader, ValueTask>The function that receives the reader.
behaviorCommandBehaviorThe behavior to use with the data reader. The default is Default.
cancellationTokenCancellationTokenThe 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
commandorhandleris 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
commandDbCommandThe DbCommand to generate a reader from.
handlerFunc<DbDataReader, ValueTask>The function that receives the reader.
cancellationTokenCancellationTokenThe 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
commandorhandleris 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
commandDbCommandThe DbCommand to generate a reader from.
handlerFunc<DbDataReader, ValueTask>The function that receives the reader.
behaviorCommandBehaviorThe behavior to use with the data reader. The default is Default.
cancellationTokenCancellationTokenThe 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
commandorhandleris 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
commandDbCommandThe DbCommand to generate a reader from.
transformFunc<DbDataReader, T>The function that receives the reader and returns the result.
cancellationTokenCancellationTokenThe 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
TThe 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
commandortransformis 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
commandDbCommandThe DbCommand to generate a reader from.
transformFunc<DbDataReader, T>The function that receives the reader and returns the result.
behaviorCommandBehaviorThe behavior to use with the data reader. The default is Default.
cancellationTokenCancellationTokenThe 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
TThe 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
commandortransformis 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
commandIDbCommandThe IDbCommand to generate a reader from.
transformFunc<IDataReader, ValueTask<T>>The function that receives the reader and returns the result.
cancellationTokenCancellationTokenThe 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
TThe 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
commandortransformis 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
commandIDbCommandThe IDbCommand to generate a reader from.
transformFunc<IDataReader, ValueTask<T>>The function that receives the reader and returns the result.
behaviorCommandBehaviorThe behavior to use with the data reader. The default is Default.
cancellationTokenCancellationTokenThe 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
TThe 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
commandortransformis 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
commandDbCommandThe DbCommand to generate a reader from.
transformFunc<DbDataReader, ValueTask<T>>The function that receives the reader and returns the result.
cancellationTokenCancellationTokenThe 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
TThe 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
commandortransformis 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
commandDbCommandThe DbCommand to generate a reader from.
transformFunc<DbDataReader, ValueTask<T>>The function that receives the reader and returns the result.
behaviorCommandBehaviorThe behavior to use with the data reader. The default is Default.
cancellationTokenCancellationTokenThe 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
TThe 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
commandortransformis null.