Method ToChannelReader
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Channel.dll
ToChannelReader<T>(IMappedQuery<T>, CancellationToken)
Reads the query into a new unbounded channel and returns its reader.
public static ChannelReader<T> ToChannelReader<T>(this IMappedQuery<T> source, CancellationToken cancellationToken = default)
Parameters
sourceIMappedQuery<T>The mapped query to read.
cancellationTokenCancellationTokenCancels the read.
Returns
- ChannelReader<T>
The reader of the new channel.
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 read the channel; the rows you have not read wait in memory.
The channel is always completed: without an error after the last row, or with the exception that ended the read, a cancel included.
Exceptions
- ArgumentNullException
sourceis null.- OperationCanceledException
cancellationTokenis already canceled.
ToChannelReader<T>(IMappedQuery<T>, bool, CancellationToken)
Reads the query into a new unbounded channel and returns its reader.
public static ChannelReader<T> ToChannelReader<T>(this IMappedQuery<T> source, bool singleReader, CancellationToken cancellationToken = default)
Parameters
sourceIMappedQuery<T>The mapped query to read.
singleReaderbooltrue if at most one consumer reads the channel at a time.
cancellationTokenCancellationTokenCancels the read.
Returns
- ChannelReader<T>
The reader of the new channel.
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 read the channel; the rows you have not read wait in memory.
The channel is always completed: without an error after the last row, or with the exception that ended the read, a cancel included.
Exceptions
- ArgumentNullException
sourceis null.- OperationCanceledException
cancellationTokenis already canceled.