Table of Contents

Method AsSourceBlockAsync

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Dataflow.dll

AsSourceBlockAsync(IDataReader, DataflowBlockOptions?, CancellationToken)

Starts reading an IDataReader in the background and returns a new BufferBlock<T> that receives each record as an array of values as it is read.

public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IDataReader reader, DataflowBlockOptions? options = null, CancellationToken cancellationToken = default)

Parameters

reader IDataReader

The data reader to iterate. The caller owns it: it is not closed or disposed here, and it must stay open until the operation completes.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

cancellationToken CancellationToken

A token that can cancel the reading. The block is then faulted with the resulting exception.

Returns

IReceivableSourceBlock<object[]>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync(IDataReader, ArrayPool<object>, DataflowBlockOptions?, CancellationToken)

Starts reading an IDataReader in the background and returns a new BufferBlock<T> that receives each record as an array of values rented from an array pool as it is read.

public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IDataReader reader, ArrayPool<object> arrayPool, DataflowBlockOptions? options = null, CancellationToken cancellationToken = default)

Parameters

reader IDataReader

The data reader to iterate. The caller owns it: it is not closed or disposed here, and it must stay open until the operation completes.

arrayPool ArrayPool<object>

The array pool to rent each record's array from. The consumer of the records is responsible for returning each array to the pool.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

cancellationToken CancellationToken

A token that can cancel the reading. The block is then faulted with the resulting exception.

Returns

IReceivableSourceBlock<object[]>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync<T>(IDataReader, Func<IDataRecord, T>, DataflowBlockOptions?, CancellationToken)

Starts reading an IDataReader in the background and returns a new BufferBlock<T> that receives each record after it has been transformed by transform as it is read.

public static IReceivableSourceBlock<T> AsSourceBlockAsync<T>(this IDataReader reader, Func<IDataRecord, T> transform, DataflowBlockOptions? options = null, CancellationToken cancellationToken = default)

Parameters

reader IDataReader

The data reader to iterate. The caller owns it: it is not closed or disposed here, and it must stay open until the operation completes.

transform Func<IDataRecord, T>

The function that transforms each IDataRecord into the item delivered to the block.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

cancellationToken CancellationToken

A token that can cancel the reading. The block is then faulted with the resulting exception.

Returns

IReceivableSourceBlock<T>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Type Parameters

T

The type of the items delivered to the block: the return type of the transform function.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync<T>(IDataReader, DataflowBlockOptions?, CancellationToken)

Starts reading an IDataReader in the background and returns a new BufferBlock<T> that receives each record mapped to a new instance of T as it is read.

public static IReceivableSourceBlock<T> AsSourceBlockAsync<T>(this IDataReader reader, DataflowBlockOptions? options = null, CancellationToken cancellationToken = default) where T : new()

Parameters

reader IDataReader

The data reader to iterate. The caller owns it: it is not closed or disposed here, and it must stay open until the operation completes.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

cancellationToken CancellationToken

A token that can cancel the reading. The block is then faulted with the resulting exception.

Returns

IReceivableSourceBlock<T>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Type Parameters

T

The type each record is mapped to.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync<T>(IDataReader, IEnumerable<(string Field, string? Column)>, DataflowBlockOptions?, CancellationToken)

Starts reading an IDataReader in the background and returns a new BufferBlock<T> that receives each record mapped to a new instance of T, using the field-to-column overrides as it is read.

public static IReceivableSourceBlock<T> AsSourceBlockAsync<T>(this IDataReader reader, IEnumerable<(string Field, string? Column)> fieldMappingOverrides, DataflowBlockOptions? options = null, CancellationToken cancellationToken = default) where T : new()

Parameters

reader IDataReader

The data reader to iterate. The caller owns it: it is not closed or disposed here, and it must stay open until the operation completes.

fieldMappingOverrides IEnumerable<(string Field, string Column)>

An override map of field names to column names, applied on top of the default name-based mapping.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

cancellationToken CancellationToken

A token that can cancel the reading. The block is then faulted with the resulting exception.

Returns

IReceivableSourceBlock<T>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Type Parameters

T

The type each record is mapped to.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync(IDbCommand, DataflowBlockOptions?, CancellationToken)

Starts reading the results of an IDbCommand in the background and returns a new BufferBlock<T> that receives each record as an array of values as it is read.

public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IDbCommand command, DataflowBlockOptions? options = null, CancellationToken cancellationToken = default)

Parameters

command IDbCommand

The command to execute. Its connection is opened if needed and closed again if it was opened here; neither the command nor the connection is disposed.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

cancellationToken CancellationToken

A token that can cancel the reading. The block is then faulted with the resulting exception.

Returns

IReceivableSourceBlock<object[]>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync(IDbCommand, ArrayPool<object>, DataflowBlockOptions?, CancellationToken)

Starts reading the results of an IDbCommand in the background and returns a new BufferBlock<T> that receives each record as an array of values rented from an array pool as it is read.

public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IDbCommand command, ArrayPool<object> arrayPool, DataflowBlockOptions? options = null, CancellationToken cancellationToken = default)

Parameters

command IDbCommand

The command to execute. Its connection is opened if needed and closed again if it was opened here; neither the command nor the connection is disposed.

arrayPool ArrayPool<object>

The array pool to rent each record's array from. The consumer of the records is responsible for returning each array to the pool.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

cancellationToken CancellationToken

A token that can cancel the reading. The block is then faulted with the resulting exception.

Returns

IReceivableSourceBlock<object[]>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync<T>(IDbCommand, Func<IDataRecord, T>, DataflowBlockOptions?, CancellationToken)

Starts reading the results of an IDbCommand in the background and returns a new BufferBlock<T> that receives each record after it has been transformed by transform as it is read.

public static IReceivableSourceBlock<T> AsSourceBlockAsync<T>(this IDbCommand command, Func<IDataRecord, T> transform, DataflowBlockOptions? options = null, CancellationToken cancellationToken = default)

Parameters

command IDbCommand

The command to execute. Its connection is opened if needed and closed again if it was opened here; neither the command nor the connection is disposed.

transform Func<IDataRecord, T>

The function that transforms each IDataRecord into the item delivered to the block.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

cancellationToken CancellationToken

A token that can cancel the reading. The block is then faulted with the resulting exception.

Returns

IReceivableSourceBlock<T>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Type Parameters

T

The type of the items delivered to the block: the return type of the transform function.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync<T>(IDbCommand, DataflowBlockOptions?, CancellationToken)

Starts reading the results of an IDbCommand in the background and returns a new BufferBlock<T> that receives each record mapped to a new instance of T as it is read.

public static IReceivableSourceBlock<T> AsSourceBlockAsync<T>(this IDbCommand command, DataflowBlockOptions? options = null, CancellationToken cancellationToken = default) where T : new()

Parameters

command IDbCommand

The command to execute. Its connection is opened if needed and closed again if it was opened here; neither the command nor the connection is disposed.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

cancellationToken CancellationToken

A token that can cancel the reading. The block is then faulted with the resulting exception.

Returns

IReceivableSourceBlock<T>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Type Parameters

T

The type each record is mapped to.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync<T>(IDbCommand, IEnumerable<(string Field, string? Column)>, DataflowBlockOptions?, CancellationToken)

Starts reading the results of an IDbCommand in the background and returns a new BufferBlock<T> that receives each record mapped to a new instance of T, using the field-to-column overrides as it is read.

public static IReceivableSourceBlock<T> AsSourceBlockAsync<T>(this IDbCommand command, IEnumerable<(string Field, string? Column)> fieldMappingOverrides, DataflowBlockOptions? options = null, CancellationToken cancellationToken = default) where T : new()

Parameters

command IDbCommand

The command to execute. Its connection is opened if needed and closed again if it was opened here; neither the command nor the connection is disposed.

fieldMappingOverrides IEnumerable<(string Field, string Column)>

An override map of field names to column names, applied on top of the default name-based mapping.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

cancellationToken CancellationToken

A token that can cancel the reading. The block is then faulted with the resulting exception.

Returns

IReceivableSourceBlock<T>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Type Parameters

T

The type each record is mapped to.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync(IExecuteReader, DataflowBlockOptions?)

Starts reading the results of an IExecuteReader in the background and returns a new BufferBlock<T> that receives each record as an array of values as it is read.

public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IExecuteReader command, DataflowBlockOptions? options = null)

Parameters

command IExecuteReader

The expressive command to execute. The connection follows the command's ownership rules: it is opened only if needed and released when reading finishes. The command's own cancellation token applies.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

Returns

IReceivableSourceBlock<object[]>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync(IExecuteReader, ArrayPool<object>, DataflowBlockOptions?)

Starts reading the results of an IExecuteReader in the background and returns a new BufferBlock<T> that receives each record as an array of values rented from an array pool as it is read.

public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IExecuteReader command, ArrayPool<object> arrayPool, DataflowBlockOptions? options = null)

Parameters

command IExecuteReader

The expressive command to execute. The connection follows the command's ownership rules: it is opened only if needed and released when reading finishes. The command's own cancellation token applies.

arrayPool ArrayPool<object>

The array pool to rent each record's array from. The consumer of the records is responsible for returning each array to the pool.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

Returns

IReceivableSourceBlock<object[]>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync<T>(IExecuteReader, Func<IDataRecord, T>, DataflowBlockOptions?)

Starts reading the results of an IExecuteReader in the background and returns a new BufferBlock<T> that receives each record after it has been transformed by transform as it is read.

public static IReceivableSourceBlock<T> AsSourceBlockAsync<T>(this IExecuteReader command, Func<IDataRecord, T> transform, DataflowBlockOptions? options = null)

Parameters

command IExecuteReader

The expressive command to execute. The connection follows the command's ownership rules: it is opened only if needed and released when reading finishes. The command's own cancellation token applies.

transform Func<IDataRecord, T>

The function that transforms each IDataRecord into the item delivered to the block.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

Returns

IReceivableSourceBlock<T>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Type Parameters

T

The type of the items delivered to the block: the return type of the transform function.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync<T>(IExecuteReader, DataflowBlockOptions?)

Starts reading the results of an IExecuteReader in the background and returns a new BufferBlock<T> that receives each record mapped to a new instance of T as it is read.

public static IReceivableSourceBlock<T> AsSourceBlockAsync<T>(this IExecuteReader command, DataflowBlockOptions? options = null) where T : new()

Parameters

command IExecuteReader

The expressive command to execute. The connection follows the command's ownership rules: it is opened only if needed and released when reading finishes. The command's own cancellation token applies.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

Returns

IReceivableSourceBlock<T>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Type Parameters

T

The type each record is mapped to.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.

AsSourceBlockAsync<T>(IExecuteReader, IEnumerable<(string Field, string? Column)>, DataflowBlockOptions?)

Starts reading the results of an IExecuteReader in the background and returns a new BufferBlock<T> that receives each record mapped to a new instance of T, using the field-to-column overrides as it is read.

public static IReceivableSourceBlock<T> AsSourceBlockAsync<T>(this IExecuteReader command, IEnumerable<(string Field, string? Column)> fieldMappingOverrides, DataflowBlockOptions? options = null) where T : new()

Parameters

command IExecuteReader

The expressive command to execute. The connection follows the command's ownership rules: it is opened only if needed and released when reading finishes. The command's own cancellation token applies.

fieldMappingOverrides IEnumerable<(string Field, string Column)>

An override map of field names to column names, applied on top of the default name-based mapping.

options DataflowBlockOptions

Options for the returned block, such as its bounded capacity, or null for the defaults.

Returns

IReceivableSourceBlock<T>

The block that receives the records. It is completed after the last record has been delivered, or faulted with the exception that ended the reading.

Type Parameters

T

The type each record is mapped to.

Remarks

The call returns immediately; reading continues on a background task and sends each record with SendAsync<TInput>(ITargetBlock<TInput>, TInput), which waits for room in a bounded block. Asynchronous database calls are used when the reader or command derives from the Db* base types. Failures are reported only through the returned block's Completion.