Method IterateWhileAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
IterateWhileAsync(DbDataReader, Func<IDataRecord, bool>, CancellationToken)
Iterates an IDataReader while the predicate returns true.
public static ValueTask IterateWhileAsync(this DbDataReader reader, Func<IDataRecord, bool> predicate, CancellationToken cancellationToken = default)
Parameters
readerDbDataReaderThe IDataReader to iterate.
predicateFunc<IDataRecord, bool>The handler function that processes each IDataRecord and decides if iteration should continue.
cancellationTokenCancellationTokenAn optional cancellation token for stopping the iteration.
Returns
IterateWhileAsync(DbDataReader, Func<IDataRecord, bool>, bool, CancellationToken)
Iterates an IDataReader while the predicate returns true.
public static ValueTask IterateWhileAsync(this DbDataReader reader, Func<IDataRecord, bool> predicate, bool useReadAsync, CancellationToken cancellationToken = default)
Parameters
readerDbDataReaderThe DbDataReader to load data from.
predicateFunc<IDataRecord, bool>The handler function that processes each IDataRecord and decides if iteration should continue.
useReadAsyncboolIf true 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
IterateWhileAsync(IDataReader, Func<IDataRecord, ValueTask<bool>>, CancellationToken)
Iterates an IDataReader while the predicate returns true.
public static ValueTask IterateWhileAsync(this IDataReader reader, Func<IDataRecord, ValueTask<bool>> predicate, CancellationToken cancellationToken = default)
Parameters
readerIDataReaderThe IDataReader to iterate.
predicateFunc<IDataRecord, ValueTask<bool>>The handler function that processes each IDataRecord and decides if iteration should continue.
cancellationTokenCancellationTokenAn optional cancellation token for stopping the iteration.
Returns
IterateWhileAsync(IDataReader, Func<IDataRecord, ValueTask<bool>>, bool, CancellationToken)
Iterates an IDataReader while the predicate returns true.
public static ValueTask IterateWhileAsync(this IDataReader reader, Func<IDataRecord, ValueTask<bool>> predicate, bool useReadAsync, CancellationToken cancellationToken = default)
Parameters
readerIDataReaderThe IDataReader to iterate.
predicateFunc<IDataRecord, ValueTask<bool>>The handler function that processes each IDataRecord and decides if iteration should continue.
useReadAsyncboolIf true will iterate the results using .ReadAsync() otherwise will only Execute the reader asynchronously and then use .Read() to iterate the results.
cancellationTokenCancellationTokenOptional cancellation token.