Table of Contents

Method AsSourceBlock

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

AsSourceBlock(IDataReader, DataflowBlockOptions?)

Reads an IDataReader to the end, posting each record as an array of values to a new BufferBlock<T>, and returns the block.

public static IReceivableSourceBlock<object[]> AsSourceBlock(this IDataReader reader, DataflowBlockOptions? options = null)

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.

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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Exceptions

ArgumentNullException

reader is null.

AsSourceBlock(IDataReader, ArrayPool<object>, DataflowBlockOptions?)

Reads an IDataReader to the end, posting each record as an array of values rented from an array pool to a new BufferBlock<T>, and returns the block.

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

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.

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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Exceptions

ArgumentNullException

reader is null.

AsSourceBlock<T>(IDataReader, Func<IDataRecord, T>, DataflowBlockOptions?)

Reads an IDataReader to the end, posting each record after it has been transformed by transform to a new BufferBlock<T>, and returns the block.

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

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.

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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Exceptions

ArgumentNullException

reader is null.

AsSourceBlock<T>(IDataReader, DataflowBlockOptions?)

Reads an IDataReader to the end, posting each record mapped to a new instance of T to a new BufferBlock<T>, and returns the block.

public static IReceivableSourceBlock<T> AsSourceBlock<T>(this IDataReader reader, DataflowBlockOptions? options = null) 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.

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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Mapping is done by an internal pipeline, so the last records and the completion of the block can arrive shortly after this method returns.

Exceptions

ArgumentNullException

reader is null.

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

Reads an IDataReader to the end, posting each record mapped to a new instance of T, using the field-to-column overrides to a new BufferBlock<T>, and returns the block.

public static IReceivableSourceBlock<T> AsSourceBlock<T>(this IDataReader reader, IEnumerable<(string Field, string? Column)> fieldMappingOverrides, DataflowBlockOptions? options = null) 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.

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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Mapping is done by an internal pipeline, so the last records and the completion of the block can arrive shortly after this method returns.

Exceptions

ArgumentNullException

reader is null.

AsSourceBlock(IDbCommand, DataflowBlockOptions?)

Reads the results of an IDbCommand to the end, posting each record as an array of values to a new BufferBlock<T>, and returns the block.

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

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.

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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Exceptions

ArgumentNullException

command is null.

AsSourceBlock(IDbCommand, ArrayPool<object>, DataflowBlockOptions?)

Reads the results of an IDbCommand to the end, posting each record as an array of values rented from an array pool to a new BufferBlock<T>, and returns the block.

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

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.

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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Exceptions

ArgumentNullException

command is null.

AsSourceBlock<T>(IDbCommand, Func<IDataRecord, T>, DataflowBlockOptions?)

Reads the results of an IDbCommand to the end, posting each record after it has been transformed by transform to a new BufferBlock<T>, and returns the block.

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

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.

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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Exceptions

ArgumentNullException

command is null.

AsSourceBlock<T>(IDbCommand, DataflowBlockOptions?)

Reads the results of an IDbCommand to the end, posting each record mapped to a new instance of T to a new BufferBlock<T>, and returns the block.

public static IReceivableSourceBlock<T> AsSourceBlock<T>(this IDbCommand command, DataflowBlockOptions? options = null) 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.

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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Mapping is done by an internal pipeline, so the last records and the completion of the block can arrive shortly after this method returns.

Exceptions

ArgumentNullException

command is null.

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

Reads the results of an IDbCommand to the end, posting each record mapped to a new instance of T, using the field-to-column overrides to a new BufferBlock<T>, and returns the block.

public static IReceivableSourceBlock<T> AsSourceBlock<T>(this IDbCommand command, IEnumerable<(string Field, string? Column)> fieldMappingOverrides, DataflowBlockOptions? options = null) 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.

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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Mapping is done by an internal pipeline, so the last records and the completion of the block can arrive shortly after this method returns.

Exceptions

ArgumentNullException

command is null.

AsSourceBlock(IExecuteReader, DataflowBlockOptions?)

Reads the results of an IExecuteReader to the end, posting each record as an array of values to a new BufferBlock<T>, and returns the block.

public static IReceivableSourceBlock<object[]> AsSourceBlock(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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Exceptions

ArgumentNullException

command is null.

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

Reads the results of an IExecuteReader to the end, posting each record as an array of values rented from an array pool to a new BufferBlock<T>, and returns the block.

public static IReceivableSourceBlock<object[]> AsSourceBlock(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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Exceptions

ArgumentNullException

command is null.

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

Reads the results of an IExecuteReader to the end, posting each record after it has been transformed by transform to a new BufferBlock<T>, and returns the block.

public static IReceivableSourceBlock<T> AsSourceBlock<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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Exceptions

ArgumentNullException

command is null.

AsSourceBlock<T>(IExecuteReader, DataflowBlockOptions?)

Reads the results of an IExecuteReader to the end, posting each record mapped to a new instance of T to a new BufferBlock<T>, and returns the block.

public static IReceivableSourceBlock<T> AsSourceBlock<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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Mapping is done by an internal pipeline, so the last records and the completion of the block can arrive shortly after this method returns.

Exceptions

ArgumentNullException

command is null.

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

Reads the results of an IExecuteReader to the end, posting each record mapped to a new instance of T, using the field-to-column overrides to a new BufferBlock<T>, and returns the block.

public static IReceivableSourceBlock<T> AsSourceBlock<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

This method is synchronous: it returns only after the source has been read to the end (or the block declined a record), so the calling thread is blocked while the database responds. Exceptions from reading propagate to the caller.

Records are posted without waiting for room. With the default unbounded options every record is accepted, but if options sets a bounded capacity, a full block declines the next record, which silently stops the reading early and drops that record. Use the AsSourceBlockAsync overloads for a bounded block, or when the caller should not be blocked.

Mapping is done by an internal pipeline, so the last records and the completion of the block can arrive shortly after this method returns.

Exceptions

ArgumentNullException

command is null.