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
sourceIMappedQuery<T>The mapped query to read.
cancellationTokenCancellationTokenCancels the read.
Returns
- IReceivableSourceBlock<T>
The new block.
Type Parameters
TThe 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
sourceis null.- OperationCanceledException
cancellationTokenis 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
sourceIMappedQuery<T>The mapped query to read.
optionsDataflowBlockOptionsThe 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.
cancellationTokenCancellationTokenCancels the read.
Returns
- IReceivableSourceBlock<T>
The new block.
Type Parameters
TThe 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
sourceoroptionsis null.- OperationCanceledException
cancellationTokenis already canceled.