System.Collections.Async.IAsyncEnumerableExtensions
Extension methods for IAsyncEnumerable<T> interface
public static IAsyncEnumerable<List<TSource>> Batch<TSource>(this IAsyncEnumerable<TSource> source, int batchSize)
Splits the input collection into series of batches.
public static IAsyncEnumerable<TStandardCollection> Batch<TSource, TStandardCollection>(this IAsyncEnumerable<TSource> source, int batchSize)
Splits the input collection into series of batches.
public static IAsyncEnumerable<List<TSource>> Batch<TSource>(this IAsyncEnumerable<TSource> source, long maxBatchWeight, Func<TSource, long> weightSelector)
Splits the input collection into series of batches.
public static IAsyncEnumerable<TStandardCollection> Batch<TSource, TStandardCollection>(this IAsyncEnumerable<TSource> source, long maxBatchWeight, Func<TSource, long> weightSelector)
Splits the input collection into series of batches.
public static IAsyncEnumerable<List<TSource>> Batch<TSource>(this IAsyncEnumerable<TSource> source, int maxItemsInBatch, long maxBatchWeight, Func<TSource, long> weightSelector)
Splits the input collection into series of batches.
public static IAsyncEnumerable<TStandardCollection> Batch<TSource, TStandardCollection>(this IAsyncEnumerable<TSource> source, int maxItemsInBatch, long maxBatchWeight, Func<TSource, long> weightSelector)
Splits the input collection into series of batches.
public static IAsyncEnumerable<TBatch> Batch<TSource, TBatch>(this IAsyncEnumerable<TSource> source, int? maxItemsInBatch, long maxBatchWeight, Func<TSource, long> weightSelector, Func<int?, TBatch> createBatch, Action<TBatch, TSource> addItem)
Splits the input collection into series of batches.
Casts the elements of an IAsyncEnumerable to the specified type.
public static IAsyncEnumerable<TSource> DefaultIfEmpty<TSource>(this IAsyncEnumerable<TSource> source)
Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.
public static IAsyncEnumerable<TSource> DefaultIfEmpty<TSource>(this IAsyncEnumerable<TSource> source, TSource defaultValue)
Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.
public static Task<TSource> FirstAsync<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken token = default)
Returns the first element in the IAsyncEnumerable<T>.
public static Task<TSource> FirstAsync<TSource>(this IAsyncEnumerable<TSource> source, string exceptionMessage, CancellationToken token = default)
Returns the first element in the IAsyncEnumerable<T>.
public static Task<TSource> FirstAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken token = default)
Returns the first element in a sequence that satisfies a specified condition.
public static Task<TSource> FirstAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, string exceptionMessage, CancellationToken token = default)
Returns the first element in a sequence that satisfies a specified condition.
public static Task<TSource> FirstOrDefaultAsync<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken token = default)
Returns the first element in the IAsyncEnumerable<T>, or a default value if no element is found.
public static Task<TSource> FirstOrDefaultAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken token = default)
Returns the first element in a sequence that satisfies a specified condition, or a default value if no element is found.
public static IAsyncEnumerable<TResult> Select<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, TResult> selector)
Projects each element of a sequence into a new form.
public static IAsyncEnumerable<TResult> Select<TSource, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, long, TResult> selector)
Projects each element of a sequence into a new form.
public static Task<TSource> SingleAsync<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken token = default)
Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.
public static Task<TSource> SingleAsync<TSource>(this IAsyncEnumerable<TSource> source, string noneExceptionMessage, string manyExceptionMessage, CancellationToken token = default)
Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.
public static Task<TSource> SingleAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken token = default)
Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence that matches the criteria.
public static Task<TSource> SingleAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, string noneExceptionMessage, string manyExceptionMessage, CancellationToken token = default)
Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence that matches the criteria.
public static Task<TSource> SingleOrDefaultAsync<TSource>(this IAsyncEnumerable<TSource> source, CancellationToken token = default)
Returns the only element of a sequence, and returns a default value if there is not exactly one element in the sequence.
public static Task<TSource> SingleOrDefaultAsync<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate, CancellationToken token = default)
Returns the only element of a sequence, and returns a default value if there is not exactly one element in the sequence that matches the criteria.
public static IAsyncEnumerable<TSource> Skip<TSource>(this IAsyncEnumerable<TSource> source, int count)
An IAsyncEnumerable<T> to return elements from.
public static IAsyncEnumerable<TSource> SkipWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements.
public static IAsyncEnumerable<TSource> Take<TSource>(this IAsyncEnumerable<TSource> source, int count)
Returns a specified number of contiguous elements from the start of a sequence.
public static IAsyncEnumerable<TSource> TakeWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
Returns elements from a sequence as long as a specified condition is true.
public static Task<T[]> ToArrayAsync<T>(this IAsyncEnumerable<T> source, CancellationToken cancellationToken = default)
Creates an array of elements asynchronously from the enumerable source
public static Task<List<T>> ToListAsync<T>(this IAsyncEnumerable<T> source, CancellationToken cancellationToken = default)
Creates a list of elements asynchronously from the enumerable source
public static IAsyncEnumerable<T> UnionAll<T>(this IAsyncEnumerable<T> first, IAsyncEnumerable<T> second)
Produces the set union of two sequences, which includes duplicate elements.
Produces the set union of multiple sequences, which includes duplicate elements.
public static IAsyncEnumerable<TSource> Where<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, bool> predicate)
Filters a sequence of values based on a predicate.
public static IAsyncEnumerable<TSource> Where<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, long, bool> predicate)
Projects each element of a sequence into a new form.