Table of Contents

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

handler Func<IDataReader, ValueTask>

The function that processes the data reader.

behavior CommandBehavior

The 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

transform Func<IDataReader, ValueTask<T>>

The function that processes the data reader and produces the result.

behavior CommandBehavior

The CommandBehavior to run the reader with. The default is Default.

Returns

ValueTask<T>

A task that produces the result of transform.

Type Parameters

T

The 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

state TState

The state to pass to the transform.

transform Func<IDataReader, TState, ValueTask<TResult>>

The function that processes the data reader.

behavior CommandBehavior

The CommandBehavior to run the reader with. The default is Default.

Returns

ValueTask<TResult>

A task that produces the result of transform.

Type Parameters

TState

The type of the state passed to the transform.

TResult

The 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

state TState

The state to pass to the transform.

transform Func<IDataReader, TState, ValueTask<TResult>>

The function that processes the data reader.

behavior CommandBehavior

The CommandBehavior to run the reader with. The default is Default.

cancellationToken CancellationToken

The 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 transform makes.

Returns

ValueTask<TResult>

A task that produces the result of transform.

Type Parameters

TState

The type of the state passed to the transform.

TResult

The type the transform returns.

Exceptions

OperationCanceledException

cancellationToken was canceled.