Table of Contents

Method ToChannelHoldingConnection

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

ToChannelHoldingConnection<T>(IMappedQuery<T>, Channel<T>, TimeSpan, CancellationToken)

Reads the query one row at a time and writes each row to a channel you own, leaving the channel open.

public static ValueTask<long> ToChannelHoldingConnection<T>(this IMappedQuery<T> source, Channel<T> channel, TimeSpan stallTimeout, CancellationToken cancellationToken = default)

Parameters

source IMappedQuery<T>

The mapped query to read.

channel Channel<T>

The channel to write to.

stallTimeout TimeSpan

The longest the channel may make no room while the reader is held. Required; passed to Stream. The wait for room before the command runs is not timed.

cancellationToken CancellationToken

Cancels the pass.

Returns

ValueTask<long>

The number of rows written to the channel.

Type Parameters

T

The type of each row.

Remarks

Holds the reader and the connection open for each row: while the channel is full, the next row is not pulled and the connection stays open until stallTimeout expires (never, with InfiniteTimeSpan). Use ToChannel<T>(IMappedQuery<T>, Channel<T>, CancellationToken), which frees the connection first, unless the rows must be pulled one at a time; otherwise it behaves as that member. See StreamBuffered(TimeSpan, int, CancellationToken) (with a buffer of one row) for the stall rules.

Exceptions

ArgumentNullException

source or channel is null.

ArgumentOutOfRangeException

stallTimeout is zero or negative and not InfiniteTimeSpan.

OperationCanceledException

cancellationToken is already canceled.

TimeoutException

The channel made no room for stallTimeout.

ToChannelHoldingConnection<T>(IMappedQuery<T>, Channel<T>, TimeSpan, bool, CancellationToken)

Reads the query one row at a time and writes each row to a channel you own, leaving the channel open.

public static ValueTask<long> ToChannelHoldingConnection<T>(this IMappedQuery<T> source, Channel<T> channel, TimeSpan stallTimeout, bool complete, CancellationToken cancellationToken = default)

Parameters

source IMappedQuery<T>

The mapped query to read.

channel Channel<T>

The channel to write to.

stallTimeout TimeSpan

The longest the channel may make no room while the reader is held. Required; passed to Stream. The wait for room before the command runs is not timed.

complete bool

true to complete the channel when the pass ends, with the exception that ended it if there was one.

cancellationToken CancellationToken

Cancels the pass.

Returns

ValueTask<long>

The number of rows written to the channel.

Type Parameters

T

The type of each row.

Remarks

Holds the reader and the connection open for each row: while the channel is full, the next row is not pulled and the connection stays open until stallTimeout expires (never, with InfiniteTimeSpan). Use ToChannel<T>(IMappedQuery<T>, Channel<T>, CancellationToken), which frees the connection first, unless the rows must be pulled one at a time; otherwise it behaves as that member. See StreamBuffered(TimeSpan, int, CancellationToken) (with a buffer of one row) for the stall rules.

Exceptions

ArgumentNullException

source or channel is null.

ArgumentOutOfRangeException

stallTimeout is zero or negative and not InfiniteTimeSpan.

OperationCanceledException

cancellationToken is already canceled.

TimeoutException

The channel made no room for stallTimeout.

ToChannelHoldingConnection<T>(IMappedQuery<T>, ChannelWriter<T>, TimeSpan, CancellationToken)

Reads the query one row at a time and writes each row to a channel you own, leaving the channel open.

public static ValueTask<long> ToChannelHoldingConnection<T>(this IMappedQuery<T> source, ChannelWriter<T> writer, TimeSpan stallTimeout, CancellationToken cancellationToken = default)

Parameters

source IMappedQuery<T>

The mapped query to read.

writer ChannelWriter<T>

The writer to write to.

stallTimeout TimeSpan

The longest the writer may make no room while the reader is held. Required; passed to Stream. The wait for room before the command runs is not timed.

cancellationToken CancellationToken

Cancels the pass.

Returns

ValueTask<long>

The number of rows written to the channel.

Type Parameters

T

The type of each row.

Remarks

Holds the reader and the connection open for each row: while the channel is full, the next row is not pulled and the connection stays open until stallTimeout expires (never, with InfiniteTimeSpan). Use ToChannel<T>(IMappedQuery<T>, Channel<T>, CancellationToken), which frees the connection first, unless the rows must be pulled one at a time; otherwise it behaves as that member. See StreamBuffered(TimeSpan, int, CancellationToken) (with a buffer of one row) for the stall rules.

Exceptions

ArgumentNullException

source or channel is null.

ArgumentOutOfRangeException

stallTimeout is zero or negative and not InfiniteTimeSpan.

OperationCanceledException

cancellationToken is already canceled.

TimeoutException

The channel made no room for stallTimeout.

ToChannelHoldingConnection<T>(IMappedQuery<T>, ChannelWriter<T>, TimeSpan, bool, CancellationToken)

Reads the query one row at a time and writes each row to a channel you own, leaving the channel open.

public static ValueTask<long> ToChannelHoldingConnection<T>(this IMappedQuery<T> source, ChannelWriter<T> writer, TimeSpan stallTimeout, bool complete, CancellationToken cancellationToken = default)

Parameters

source IMappedQuery<T>

The mapped query to read.

writer ChannelWriter<T>

The writer to write to.

stallTimeout TimeSpan

The longest the writer may make no room while the reader is held. Required; passed to Stream. The wait for room before the command runs is not timed.

complete bool

true to complete the writer when the pass ends, with the exception that ended it if there was one.

cancellationToken CancellationToken

Cancels the pass.

Returns

ValueTask<long>

The number of rows written to the channel.

Type Parameters

T

The type of each row.

Remarks

Holds the reader and the connection open for each row: while the channel is full, the next row is not pulled and the connection stays open until stallTimeout expires (never, with InfiniteTimeSpan). Use ToChannel<T>(IMappedQuery<T>, Channel<T>, CancellationToken), which frees the connection first, unless the rows must be pulled one at a time; otherwise it behaves as that member. See StreamBuffered(TimeSpan, int, CancellationToken) (with a buffer of one row) for the stall rules.

Exceptions

ArgumentNullException

source or channel is null.

ArgumentOutOfRangeException

stallTimeout is zero or negative and not InfiniteTimeSpan.

OperationCanceledException

cancellationToken is already canceled.

TimeoutException

The channel made no room for stallTimeout.