Method ForEachAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
ForEachAsync(DbDataReader, Action<IDataRecord>, bool, CancellationToken)
Iterates all records from an DbDataReader.
public static ValueTask ForEachAsync(this DbDataReader reader, Action<IDataRecord> handler, bool useReadAsync = true, CancellationToken cancellationToken = default)
Parameters
readerDbDataReaderThe IDataReader to iterate.
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.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
ForEachAsync(DbDataReader, Func<IDataRecord, ValueTask>, bool, CancellationToken)
Iterates all records from an DbDataReader.
public static ValueTask ForEachAsync(this DbDataReader reader, Func<IDataRecord, ValueTask> handler, bool useReadAsync = true, CancellationToken cancellationToken = default)
Parameters
readerDbDataReaderThe IDataReader to iterate.
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.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
ForEachAsync(DbDataReader, Func<IDataRecord, ValueTask>, CancellationToken)
Iterates all records from an DbDataReader.
public static ValueTask ForEachAsync(this DbDataReader reader, Func<IDataRecord, ValueTask> handler, CancellationToken cancellationToken)
Parameters
readerDbDataReaderThe IDataReader to iterate.
handlerFunc<IDataRecord, ValueTask>The handler function for each IDataRecord.
cancellationTokenCancellationTokenOptional cancellation token.