Table of Contents

Method ReadAsync

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

ReadAsync(Func<IAsyncEnumerable<T>, CancellationToken, ValueTask>, CancellationToken)

Asynchronously executes the query and passes the mapped rows to handler as they are read.

public ValueTask ReadAsync(Func<IAsyncEnumerable<T>, CancellationToken, ValueTask> handler, CancellationToken cancellationToken)

Parameters

handler Func<IAsyncEnumerable<T>, CancellationToken, ValueTask>

Receives a forward-only asynchronous sequence of mapped rows and the cancellation token in effect. Enumerate it inside the handler; it is not valid after the handler returns.

cancellationToken CancellationToken

Cancels the operation. The implementations in this library use the command's own cancellation token when this one cannot be canceled.

Returns

ValueTask

A task that completes after the handler has completed and the connection has been released.

Remarks

The connection is opened if it is not already open and is released when the handler returns, whether the handler completes or throws. Exceptions from the provider propagate unchanged.

Exceptions

OperationCanceledException

The operation was canceled.

ReadAsync<TResult>(Func<IAsyncEnumerable<T>, CancellationToken, ValueTask<TResult>>, CancellationToken)

Asynchronously executes the query, passes the mapped rows to handler as they are read, and returns the handler's result.

public ValueTask<TResult> ReadAsync<TResult>(Func<IAsyncEnumerable<T>, CancellationToken, ValueTask<TResult>> handler, CancellationToken cancellationToken)

Parameters

handler Func<IAsyncEnumerable<T>, CancellationToken, ValueTask<TResult>>

Receives a forward-only asynchronous sequence of mapped rows and the cancellation token in effect. Enumerate it inside the handler; it is not valid after the handler returns.

cancellationToken CancellationToken

Cancels the operation. The implementations in this library use the command's own cancellation token when this one cannot be canceled.

Returns

ValueTask<TResult>

A task that produces the value returned by handler after the connection has been released.

Type Parameters

TResult

The type returned by the handler.

Remarks

The connection is opened if it is not already open and is released when the handler returns, whether the handler completes or throws. Exceptions from the provider propagate unchanged.

Exceptions

OperationCanceledException

The operation was canceled.