src/Shared/EntityFramework/Infrastructure/IDbAsyncEnumerableExtensions.cs
// <summary>
// Asynchronously executes the provided action on each element of the <see cref="IDbAsyncEnumerable" />.
// </summary>
// <param name="action"> The action to be executed. </param>
// <param name="cancellationToken"> The token to monitor for cancellation requests. </param>
// <returns> A Task representing the asynchronous operation. </returns>
Asynchronously executes the provided action on each element of the .
Asynchronously executes the provided action on each element of the .
internal static async Task ForEachAsync(
            this IDbAsyncEnumerable source, Action<object> action, CancellationToken cancellationToken)
        {
            DebugCheck.NotNull(source);
            DebugCheck.NotNull(action);
            cancellationToken.ThrowIfCancellationRequested();
            using (var enumerator = source.GetAsyncEnumerator())
            {
                if (await enumerator.MoveNextAsync(cancellationToken).WithCurrentCulture())
                {
                    Task<bool> moveNextTask;
                    do
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        var current = enumerator.Current;
                        moveNextTask = enumerator.MoveNextAsync(cancellationToken);
                        action(current);
                    }
                    while (await moveNextTask.WithCurrentCulture());
                }
            }
        }
internal static async Task ForEachAsync ( this IDbAsyncEnumerable source , Action < object > action , CancellationToken cancellationToken ) { DebugCheck . NotNull ( source ) ; DebugCheck . NotNull ( action ) ; cancellationToken . ThrowIfCancellationRequested ( ) ; using ( var enumerator = source . GetAsyncEnumerator ( ) ) { if ( await enumerator . MoveNextAsync ( cancellationToken ) . WithCurrentCulture ( ) ) { Task < bool > moveNextTask ; do { cancellationToken . ThrowIfCancellationRequested ( ) ; var current = enumerator . Current ; moveNextTask = enumerator . MoveNextAsync ( cancellationToken ) ; action ( current ) ; } while ( await moveNextTask . WithCurrentCulture ( ) ) ; } } }
Asynchronously executes the provided action on each element of the .
Asynchronously executes the provided action on each element of the .
A Task representing the asynchronous operation.
A Task representing the asynchronous operation .
IDbAsyncEnumerable
this
action
Action<object>
The action to be executed.
The action to be executed .
cancellationToken
CancellationToken
The token to monitor for cancellation requests.
The token to monitor for cancellation requests .