Table of Contents

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

command DbCommand

The DbCommand to generate a reader from.

predicate Func<IDataRecord, ValueTask<bool>>

The handler function that processes each IDataRecord and decides if iteration should continue.

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