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
readerIDataReaderThe data reader to iterate. The caller owns it: it is not closed or disposed here, and it must stay open until the operation completes.
optionsDataflowBlockOptionsOptions for the returned block, such as its bounded capacity, or null for the defaults.
cancellationTokenCancellationTokenA 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
readerIDataReaderThe data reader to iterate. The caller owns it: it is not closed or disposed here, and it must stay open until the operation completes.
arrayPoolArrayPool<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.
optionsDataflowBlockOptionsOptions for the returned block, such as its bounded capacity, or null for the defaults.
cancellationTokenCancellationTokenA 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
readerIDataReaderThe data reader to iterate. The caller owns it: it is not closed or disposed here, and it must stay open until the operation completes.
transformFunc<IDataRecord, T>The function that transforms each IDataRecord into the item delivered to the block.
optionsDataflowBlockOptionsOptions for the returned block, such as its bounded capacity, or null for the defaults.
cancellationTokenCancellationTokenA 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
TThe 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
readerIDataReaderThe data reader to iterate. The caller owns it: it is not closed or disposed here, and it must stay open until the operation completes.
optionsDataflowBlockOptionsOptions for the returned block, such as its bounded capacity, or null for the defaults.
cancellationTokenCancellationTokenA 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
TThe 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
readerIDataReaderThe data reader to iterate. The caller owns it: it is not closed or disposed here, and it must stay open until the operation completes.
fieldMappingOverridesIEnumerable<(string Field, string Column)>An override map of field names to column names, applied on top of the default name-based mapping.
optionsDataflowBlockOptionsOptions for the returned block, such as its bounded capacity, or null for the defaults.
cancellationTokenCancellationTokenA 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
TThe 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
commandIDbCommandThe 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.
optionsDataflowBlockOptionsOptions for the returned block, such as its bounded capacity, or null for the defaults.
cancellationTokenCancellationTokenA 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
commandIDbCommandThe 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.
arrayPoolArrayPool<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.
optionsDataflowBlockOptionsOptions for the returned block, such as its bounded capacity, or null for the defaults.
cancellationTokenCancellationTokenA 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
commandIDbCommandThe 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.
transformFunc<IDataRecord, T>The function that transforms each IDataRecord into the item delivered to the block.
optionsDataflowBlockOptionsOptions for the returned block, such as its bounded capacity, or null for the defaults.
cancellationTokenCancellationTokenA 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
TThe 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
commandIDbCommandThe 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.
optionsDataflowBlockOptionsOptions for the returned block, such as its bounded capacity, or null for the defaults.
cancellationTokenCancellationTokenA 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
TThe 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
commandIDbCommandThe 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.
fieldMappingOverridesIEnumerable<(string Field, string Column)>An override map of field names to column names, applied on top of the default name-based mapping.
optionsDataflowBlockOptionsOptions for the returned block, such as its bounded capacity, or null for the defaults.
cancellationTokenCancellationTokenA 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
TThe 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
commandIExecuteReaderThe 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.
optionsDataflowBlockOptionsOptions 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
commandIExecuteReaderThe 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.
arrayPoolArrayPool<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.
optionsDataflowBlockOptionsOptions 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
commandIExecuteReaderThe 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.
transformFunc<IDataRecord, T>The function that transforms each IDataRecord into the item delivered to the block.
optionsDataflowBlockOptionsOptions 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
TThe 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
commandIExecuteReaderThe 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.
optionsDataflowBlockOptionsOptions 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
TThe 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
commandIExecuteReaderThe 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.
fieldMappingOverridesIEnumerable<(string Field, string Column)>An override map of field names to column names, applied on top of the default name-based mapping.
optionsDataflowBlockOptionsOptions 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
TThe 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.