Table of Contents

Method AsSourceBlock

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Dataflow.dll

AsSourceBlock<T>(IMappedQuery<T>, CancellationToken)

Reads the query into a new unbounded block and returns it.

public static IReceivableSourceBlock<T> AsSourceBlock<T>(this IMappedQuery<T> source, CancellationToken cancellationToken = default)

Parameters

source IMappedQuery<T>

The mapped query to read.

cancellationToken CancellationToken

Cancels the read.

Returns

IReceivableSourceBlock<T>

The new block.

Type Parameters

T

The type of each row.

Remarks

The read starts at the call, on a background task. The query is read at full speed into pooled chunks and the connection is closed when the read ends, however slowly you receive from the block; the rows you have not received yet wait in memory.

The block is always finished: completed after the last row, or faulted with the exception that ended the read, a cancel included. A faulted block drops the rows it holds that were not received yet.

To put the rows into a pipeline you built, use ToTargetBlock<T>(IMappedQuery<T>, ITargetBlock<T>, CancellationToken).

Exceptions

ArgumentNullException

source is null.

OperationCanceledException

cancellationToken is already canceled.

See Also

AsSourceBlock<T>(IMappedQuery<T>, DataflowBlockOptions, CancellationToken)

Reads the query into a new block made from options and returns it.

public static IReceivableSourceBlock<T> AsSourceBlock<T>(this IMappedQuery<T> source, DataflowBlockOptions options, CancellationToken cancellationToken = default)

Parameters

source IMappedQuery<T>

The mapped query to read.

options DataflowBlockOptions

The options of the new block: its task scheduler, its bound and the rest. A bound limits the block, not memory: the query is still read at full speed, and the rows the block has no room for wait in an internal queue.

cancellationToken CancellationToken

Cancels the read.

Returns

IReceivableSourceBlock<T>

The new block.

Type Parameters

T

The type of each row.

Remarks

The read starts at the call, on a background task. The query is read at full speed into pooled chunks and the connection is closed when the read ends, however slowly you receive from the block; the rows you have not received yet wait in memory.

The block is always finished: completed after the last row, or faulted with the exception that ended the read, a cancel included. A faulted block drops the rows it holds that were not received yet.

To put the rows into a pipeline you built, use ToTargetBlock<T>(IMappedQuery<T>, ITargetBlock<T>, CancellationToken).

Exceptions

ArgumentNullException

source or options is null.

OperationCanceledException

cancellationToken is already canceled.