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
commandDbCommandThe DbCommand to generate a reader from.
handlerAction<IDataRecord>The handler function for each IDataRecord.
behaviorCommandBehaviorThe behavior to use with the data reader.
useReadAsyncboolIf 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.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
commandDbCommandThe DbCommand to generate a reader from.
handlerAction<IDataRecord>The handler function for each IDataRecord.
useReadAsyncboolIf 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.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
commandDbCommandThe DbCommand to generate a reader from.
handlerFunc<IDataRecord, ValueTask>The handler function for each IDataRecord.
behaviorCommandBehaviorThe behavior to use with the data reader.
useReadAsyncboolIf 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.
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
commandDbCommandThe DbCommand to generate a reader from.
handlerFunc<IDataRecord, ValueTask>The handler function for each IDataRecord.
useReadAsyncboolIf 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.
cancellationTokenCancellationTokenThe cancellation token.