Table of Contents

Method ToBoundedChannel

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Channel.dll

ToBoundedChannel<T>(IMappedQuery<T>, int, CancellationToken)

Reads the query into a new bounded channel and returns the channel.

public static Channel<T> ToBoundedChannel<T>(this IMappedQuery<T> source, int capacity, CancellationToken cancellationToken = default)

Parameters

source IMappedQuery<T>

The mapped query to read.

capacity int

The most rows the channel holds.

cancellationToken CancellationToken

Cancels the read.

Returns

Channel<T>

The new channel.

Type Parameters

T

The type of each row.

Remarks

The bound limits the channel, not memory: the query is still read at full speed, and the rows the channel has no room for wait in an internal queue.

Exceptions

ArgumentNullException

source is null.

ArgumentOutOfRangeException

capacity is less than one.

OperationCanceledException

cancellationToken is already canceled.