Table of Contents

Method ForEachAsync

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

ForEachAsync(DbCommand, Action<IDataRecord>, CommandBehavior, bool, CancellationToken)

Asynchronously iterates all records from an IDataReader.

public static ValueTask ForEachAsync(this DbCommand command, Action<IDataRecord> handler, CommandBehavior behavior, bool useReadAsync = true, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

handler Action<IDataRecord>

The handler function for each IDataRecord.

behavior CommandBehavior

The behavior to use with the data reader.

useReadAsync bool

If true (default) will iterate the results using .ReadAsync() otherwise will only Execute the reader asynchronously and then use .Read() to iterate the results but still allowing cancellation.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask

ForEachAsync(DbCommand, Action<IDataRecord>, bool, CancellationToken)

Asynchronously iterates all records from an IDataReader.

public static ValueTask ForEachAsync(this DbCommand command, Action<IDataRecord> handler, bool useReadAsync = true, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

handler Action<IDataRecord>

The handler function for each IDataRecord.

useReadAsync bool

If true (default) will iterate the results using .ReadAsync() otherwise will only Execute the reader asynchronously and then use .Read() to iterate the results but still allowing cancellation.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask

ForEachAsync(DbCommand, Func<IDataRecord, ValueTask>, CommandBehavior, bool, CancellationToken)

Asynchronously iterates all records from an IDataReader.

public static ValueTask ForEachAsync(this DbCommand command, Func<IDataRecord, ValueTask> handler, CommandBehavior behavior, bool useReadAsync = true, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

handler Func<IDataRecord, ValueTask>

The handler function for each IDataRecord.

behavior CommandBehavior

The behavior to use with the data reader.

useReadAsync bool

If true (default) will iterate the results using .ReadAsync() otherwise will only Execute the reader asynchronously and then use .Read() to iterate the results but still allowing cancellation.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask

ForEachAsync(DbCommand, Func<IDataRecord, ValueTask>, bool, CancellationToken)

Asynchronously iterates all records from an IDataReader.

public static ValueTask ForEachAsync(this DbCommand command, Func<IDataRecord, ValueTask> handler, bool useReadAsync = true, CancellationToken cancellationToken = default)

Parameters

command DbCommand

The DbCommand to generate a reader from.

handler Func<IDataRecord, ValueTask>

The handler function for each IDataRecord.

useReadAsync bool

If true (default) will iterate the results using .ReadAsync() otherwise will only Execute the reader asynchronously and then use .Read() to iterate the results but still allowing cancellation.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask