Table of Contents

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

source IMappedQuery<T>

The mapped query to read.

cancellationToken CancellationToken

Cancels the read.

Returns

ChannelReader<T>

The reader of the new channel.

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 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

source is null.

OperationCanceledException

cancellationToken is 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

source IMappedQuery<T>

The mapped query to read.

singleReader bool

true if at most one consumer reads the channel at a time.

cancellationToken CancellationToken

Cancels the read.

Returns

ChannelReader<T>

The reader of the new channel.

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 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

source is null.

OperationCanceledException

cancellationToken is already canceled.