Method IterateReaderWhileAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
IterateReaderWhileAsync(DbCommand, Func<IDataRecord, ValueTask<bool>>, CommandBehavior, bool, CancellationToken)
Asynchronously iterates an IDataReader on a command while the predicate returns true.
public static ValueTask IterateReaderWhileAsync(this DbCommand command, Func<IDataRecord, ValueTask<bool>> predicate, CommandBehavior behavior = CommandBehavior.Default, bool useReadAsync = true, CancellationToken cancellationToken = default)
Parameters
commandDbCommandThe DbCommand to generate a reader from.
predicateFunc<IDataRecord, ValueTask<bool>>The handler function that processes each IDataRecord and decides if iteration should continue.
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.