Method ExecuteReaderAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
ExecuteReaderAsync(Func<IDataReader, ValueTask>, CommandBehavior)
Asynchronously executes the command and passes the data reader to
handler.
ValueTask ExecuteReaderAsync(Func<IDataReader, ValueTask> handler, CommandBehavior behavior = CommandBehavior.Default)
Parameters
handlerFunc<IDataReader, ValueTask>The function that processes the data reader.
behaviorCommandBehaviorThe CommandBehavior to run the reader with. The default is Default.
Returns
- ValueTask
A task that represents the asynchronous operation.
ExecuteReaderAsync<T>(Func<IDataReader, ValueTask<T>>, CommandBehavior)
Asynchronously executes the command, passes the data reader to
transform and returns its result.
ValueTask<T> ExecuteReaderAsync<T>(Func<IDataReader, ValueTask<T>> transform, CommandBehavior behavior = CommandBehavior.Default)
Parameters
transformFunc<IDataReader, ValueTask<T>>The function that processes the data reader and produces the result.
behaviorCommandBehaviorThe CommandBehavior to run the reader with. The default is Default.
Returns
- ValueTask<T>
A task that produces the result of
transform.
Type Parameters
TThe type the transform returns.
ExecuteReaderAsync<TState, TResult>(TState, Func<IDataReader, TState, ValueTask<TResult>>, CommandBehavior)
Asynchronously executes the command, passes the data reader and
state to transform, and returns its
result.
Pass a static lambda and the state it needs to avoid
allocating a closure per call.
ValueTask<TResult> ExecuteReaderAsync<TState, TResult>(TState state, Func<IDataReader, TState, ValueTask<TResult>> transform, CommandBehavior behavior = CommandBehavior.Default)
Parameters
stateTStateThe state to pass to the transform.
transformFunc<IDataReader, TState, ValueTask<TResult>>The function that processes the data reader.
behaviorCommandBehaviorThe CommandBehavior to run the reader with. The default is Default.
Returns
- ValueTask<TResult>
A task that produces the result of
transform.
Type Parameters
TStateThe type of the state passed to the transform.
TResultThe type the transform returns.
ExecuteReaderAsync<TState, TResult>(TState, Func<IDataReader, TState, ValueTask<TResult>>, CommandBehavior, CancellationToken)
Asynchronously executes the command, passes the data reader and
state to transform, and returns its
result, with the cancellation token to use for the whole call.
Pass a static lambda and the state it needs to avoid
allocating a closure per call.
ValueTask<TResult> ExecuteReaderAsync<TState, TResult>(TState state, Func<IDataReader, TState, ValueTask<TResult>> transform, CommandBehavior behavior, CancellationToken cancellationToken)
Parameters
stateTStateThe state to pass to the transform.
transformFunc<IDataReader, TState, ValueTask<TResult>>The function that processes the data reader.
behaviorCommandBehaviorThe CommandBehavior to run the reader with. The default is Default.
cancellationTokenCancellationTokenThe token used for this call instead of CancellationToken; the command's own token is not consulted. It is checked before anything starts and cancels opening the connection, looking up stored-procedure parameter names and executing the command. The caller has already combined every token it wants honored (including CancellationToken), and uses the same token for the reads that
transformmakes.
Returns
- ValueTask<TResult>
A task that produces the result of
transform.
Type Parameters
TStateThe type of the state passed to the transform.
TResultThe type the transform returns.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.