src/Shared/EntityFramework/Infrastructure/IDbAsyncEnumerableExtensions.cs
// <summary>
// Asynchronously creates a <see cref="List{T}" /> from the <see cref="IDbAsyncEnumerable{T}" />.
// </summary>
// <param name="cancellationToken"> The token to monitor for cancellation requests. </param>
// <returns>
// A <see cref="Task" /> containing a <see cref="List{T}" /> that contains elements from the input sequence.
// </returns>
Asynchronously creates a  from the .
Asynchronously creates a from the .
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        internal static Task<List<T>> ToListAsync<T>(this IDbAsyncEnumerable<T> source, CancellationToken cancellationToken)
        {
            DebugCheck.NotNull(source);
            var tcs = new TaskCompletionSource<List<T>>();
            var list = new List<T>();
            source.ForEachAsync(list.Add, cancellationToken).ContinueWith(
                t =>
                {
                    if (t.IsFaulted)
                    {
                        tcs.TrySetException(t.Exception.InnerExceptions);
                    }
                    else if (t.IsCanceled)
                    {
                        tcs.TrySetCanceled();
                    }
                    else
                    {
                        tcs.TrySetResult(list);
                    }
                }, TaskContinuationOptions.ExecuteSynchronously);
            return tcs.Task;
        }
[ SuppressMessage ( " " , " " ) ] internal static Task < List < T > > ToListAsync < T > ( this IDbAsyncEnumerable < T > source , CancellationToken cancellationToken ) { DebugCheck . NotNull ( source ) ; var tcs = new TaskCompletionSource < List < T > > ( ) ; var list = new List < T > ( ) ; source . ForEachAsync ( list . Add , cancellationToken ) . ContinueWith ( t => { if ( t . IsFaulted ) { tcs . TrySetException ( t . Exception . InnerExceptions ) ; } else if ( t . IsCanceled ) { tcs . TrySetCanceled ( ) ; } else { tcs . TrySetResult ( list ) ; } } , TaskContinuationOptions . ExecuteSynchronously ) ; return tcs . Task ; }
Asynchronously creates a  from the .
Asynchronously creates a from the .
A  containing a  that contains elements from the input sequence.
A containing a that contains elements from the input sequence .
IDbAsyncEnumerable<T>
this
cancellationToken
CancellationToken
The token to monitor for cancellation requests.
The token to monitor for cancellation requests .