AsyncIterators
Namespace: SnowBank.Linq · class
Contains generic fallback implementations for custom async iterators
Methods
AllAsync
static Task<bool> AllAsync<T>(IAsyncQuery<T> source, Func<T, bool> predicate)
Determines whether any element of an async sequence satisfies a condition.
static Task<bool> AllAsync<T>(IAsyncQuery<T> source, Func<T, CancellationToken, Task<bool>> predicate)
Determines whether any element of an async sequence satisfies a condition.
AnyAsync
static Task<bool> AnyAsync<T>(IAsyncQuery<T> source)
Determines whether an async sequence contains any elements.
static Task<bool> AnyAsync<T>(IAsyncQuery<T> source, Func<T, bool> predicate)
Determines whether any element of an async sequence satisfies a condition.
static Task<bool> AnyAsync<T>(IAsyncQuery<T> source, Func<T, CancellationToken, Task<bool>> predicate)
Determines whether any element of an async sequence satisfies a condition.
CountAsync
static Task<int> CountAsync<T>(IAsyncQuery<T> source)
Returns the number of elements in an async sequence.
static Task<int> CountAsync<T>(IAsyncQuery<T> source, Func<T, bool> predicate)
Returns a number that represents how many elements in the specified async sequence satisfy a condition.
static Task<int> CountAsync<T>(IAsyncQuery<T> source, Func<T, CancellationToken, Task<bool>> predicate)
Returns a number that represents how many elements in the specified async sequence satisfy a condition.
FirstAsync
static Task<T> FirstAsync<T>(IAsyncQuery<T> source)
Returns the first element of an async sequence, or an exception if it is empty
static Task<T> FirstAsync<T>(IAsyncQuery<T> source, Func<T, bool> predicate)
Returns the first element of an async sequence, or an exception if it is empty
static Task<T> FirstAsync<T>(IAsyncQuery<T> source, Func<T, CancellationToken, Task<bool>> predicate)
Returns the first element of an async sequence, or an exception if it is empty
FirstOrDefaultAsync
static Task<T> FirstOrDefaultAsync<T>(IAsyncQuery<T> source, T defaultValue)
Returns the first element of an async sequence, or the default value for the type if it is empty
static Task<T> FirstOrDefaultAsync<T>(IAsyncQuery<T> source, Func<T, bool> predicate, T defaultValue)
Returns the first element of an async sequence, or the default value for the type if it is empty
static Task<T> FirstOrDefaultAsync<T>(IAsyncQuery<T> source, Func<T, CancellationToken, Task<bool>> predicate, T defaultValue)
Returns the first element of an async sequence, or the default value for the type if it is empty
LastAsync
static Task<T> LastAsync<T>(IAsyncQuery<T> source)
Returns the last element of an async sequence, or an exception if it is empty
static Task<T> LastAsync<T>(IAsyncQuery<T> source, Func<T, bool> predicate)
Returns the last element of an async sequence, or an exception if it is empty
static Task<T> LastAsync<T>(IAsyncQuery<T> source, Func<T, CancellationToken, Task<bool>> predicate)
Returns the last element of an async sequence, or an exception if it is empty
LastOrDefaultAsync
static Task<T> LastOrDefaultAsync<T>(IAsyncQuery<T> source, T defaultValue)
Returns the last element of an async sequence, or the default value for the type if it is empty
static Task<T> LastOrDefaultAsync<T>(IAsyncQuery<T> source, Func<T, bool> predicate, T defaultValue)
Returns the last element of an async sequence, or the default value for the type if it is empty
static Task<T> LastOrDefaultAsync<T>(IAsyncQuery<T> source, Func<T, CancellationToken, Task<bool>> predicate, T defaultValue)
Returns the last element of an async sequence, or the default value for the type if it is empty
MaxAsync
static Task<int> MaxAsync(IAsyncQuery<int> source)
Returns the largest value in the specified async sequence
static Task<long> MaxAsync(IAsyncQuery<long> source)
Returns the largest value in the specified async sequence
static Task<float> MaxAsync(IAsyncQuery<float> source)
Returns the largest value in the specified async sequence
static Task<double> MaxAsync(IAsyncQuery<double> source)
Returns the largest value in the specified async sequence
static Task<decimal> MaxAsync(IAsyncQuery<decimal> source)
Returns the largest value in the specified async sequence
static Task<T> MaxAsync<T>(IAsyncQuery<T> source, IComparer<T> comparer)
Returns the largest value in the specified async sequence
MinAsync
static Task<int> MinAsync(IAsyncQuery<int> source)
Returns the smallest value in the specified async sequence
static Task<long> MinAsync(IAsyncQuery<long> source)
Returns the smallest value in the specified async sequence
static Task<float> MinAsync(IAsyncQuery<float> source)
Returns the smallest value in the specified async sequence
static Task<double> MinAsync(IAsyncQuery<double> source)
Returns the smallest value in the specified async sequence
static Task<decimal> MinAsync(IAsyncQuery<decimal> source)
Returns the smallest value in the specified async sequence
static Task<T> MinAsync<T>(IAsyncQuery<T> source, IComparer<T> comparer)
Returns the smallest value in the specified async sequence
Select
static IAsyncLinqQuery<TResult> Select<TSource, TResult>(IAsyncQuery<TSource> source, Func<TSource, TResult> selector)
Projects each element of an async sequence into a new form.
static IAsyncLinqQuery<TResult> Select<TResult, TSource>(IAsyncQuery<TSource> source, Func<TSource, int, TResult> selector)
Projects each element of an async sequence into a new form.
static IAsyncLinqQuery<TResult> Select<TSource, TResult>(IAsyncQuery<TSource> source, Func<TSource, CancellationToken, Task<TResult>> selector)
Projects each element of an async sequence into a new form.
static IAsyncLinqQuery<TResult> Select<TResult, TSource>(IAsyncQuery<TSource> source, Func<TSource, int, CancellationToken, Task<TResult>> selector)
Projects each element of an async sequence into a new form.
SelectManyImpl
static IAsyncLinqQuery<TResult> SelectManyImpl<TSource, TResult>(IAsyncQuery<TSource> source, Func<TSource, IEnumerable<TResult>> selector)
Projects each element of an async sequence to an IEnumerable and flattens the resulting sequences into one async sequence.
static IAsyncLinqQuery<TResult> SelectManyImpl<TSource, TResult>(IAsyncQuery<TSource> source, Func<TSource, CancellationToken, Task<IEnumerable<TResult>>> selector)
Projects each element of an async sequence to an IAsyncEnumerable and flattens the resulting sequences into one async sequence.
static IAsyncLinqQuery<TResult> SelectManyImpl<TSource, TCollection, TResult>(IAsyncQuery<TSource> source, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
Projects each element of an async sequence to an IEnumerable flattens the resulting sequences into one async sequence, and invokes a result selector function on each element therein.
static IAsyncLinqQuery<TResult> SelectManyImpl<TSource, TCollection, TResult>(IAsyncQuery<TSource> source, Func<TSource, CancellationToken, Task<IEnumerable<TCollection>>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
Projects each element of an async sequence to an IEnumerable flattens the resulting sequences into one async sequence, and invokes a result selector function on each element therein.
SingleAsync
static Task<T> SingleAsync<T>(IAsyncQuery<T> source)
Returns the first and only element of an async sequence, or an exception if it is empty or have two or more elements
Will need to call MoveNext at least twice to ensure that there is no second element.
static Task<T> SingleAsync<T>(IAsyncQuery<T> source, Func<T, bool> predicate)
Returns the first and only element of an async sequence, or an exception if it is empty or have two or more elements
Will need to call MoveNext at least twice to ensure that there is no second element.
static Task<T> SingleAsync<T>(IAsyncQuery<T> source, Func<T, CancellationToken, Task<bool>> predicate)
Returns the first and only element of an async sequence, or an exception if it is empty or have two or more elements
Will need to call MoveNext at least twice to ensure that there is no second element.
SingleOrDefaultAsync
static Task<T> SingleOrDefaultAsync<T>(IAsyncQuery<T> source, T defaultValue)
Returns the first and only element of an async sequence, the default value for the type if it is empty, or an exception if it has two or more elements
Will need to call MoveNext at least twice to ensure that there is no second element.
static Task<T> SingleOrDefaultAsync<T>(IAsyncQuery<T> source, Func<T, bool> predicate, T defaultValue)
Returns the first and only element of an async sequence, the default value for the type if it is empty, or an exception if it has two or more elements
Will need to call MoveNext at least twice to ensure that there is no second element.
static Task<T> SingleOrDefaultAsync<T>(IAsyncQuery<T> source, Func<T, CancellationToken, Task<bool>> predicate, T defaultValue)
Returns the first and only element of an async sequence, the default value for the type if it is empty, or an exception if it has two or more elements
Will need to call MoveNext at least twice to ensure that there is no second element.
Skip
static IAsyncLinqQuery<TResult> Skip<TResult>(IAsyncQuery<TResult> source, int offset)
Skips the first elements of an async sequence.
SumAsync
static Task<T> SumAsync<T>(IAsyncQuery<T> source)
Sums the results of a query
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
SumDecimalAsync
static Task<decimal> SumDecimalAsync(IAsyncQuery<decimal> source)
Sums the results of a query
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
static Task<decimal?> SumDecimalAsync(IAsyncQuery<decimal?> source)
Sums the results of a query that are not null.
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
SumDoubleAsync
static Task<double> SumDoubleAsync(IAsyncQuery<double> source)
Sums the results of a query
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
static Task<double?> SumDoubleAsync(IAsyncQuery<double?> source)
Sums the results of a query that are not null.
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
SumFloatAsync
static Task<float> SumFloatAsync(IAsyncQuery<float> source)
Sums the results of a query
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
static Task<float?> SumFloatAsync(IAsyncQuery<float?> source)
Sums the results of a query that are not null.
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
SumInt32Async
static Task<int> SumInt32Async(IAsyncQuery<int> source)
Sums the results of a query
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
static Task<int?> SumInt32Async(IAsyncQuery<int?> source)
Sums the results of a query that are not null.
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
SumInt64Async
static Task<long> SumInt64Async(IAsyncQuery<long> source)
Sums the results of a query
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
static Task<long?> SumInt64Async(IAsyncQuery<long?> source)
Sums the results of a query that are not null.
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
SumNullableAsync
static Task<T?> SumNullableAsync<T>(IAsyncQuery<T?> source)
Sums the nullable results of a query
source— Query to sum
Returns: Sum of all the results, or zero if the query is empty.
SumUnconstrainedAsync
static Task<T> SumUnconstrainedAsync<T>(IAsyncLinqQuery<T> source)
Version of SumAsync that does not have a generic constraint on T, and that will perform a runtime dispatch to a compatible method
source— Query to sum
Returns: Sum of the results in the query, if T is supported
This method can be used by generic iterators that cannot place a constraint on the types of their element, but still be able to provide summing if the type supports it.
Take
static IAsyncLinqQuery<TResult> Take<TResult>(IAsyncQuery<TResult> source, int limit)
Returns a specified number of contiguous elements from the start of an async sequence.
static IAsyncLinqQuery<TResult> Take<TResult>(IAsyncQuery<TResult> source, Range range)
Returns a specified number of contiguous elements from the start of an async sequence.
TakeWhile
static IAsyncLinqQuery<TResult> TakeWhile<TResult>(IAsyncQuery<TResult> source, Func<TResult, bool> condition)
Returns elements from an async sequence as long as a specified condition is true, and then skips the remaining elements.
Where
static IAsyncLinqQuery<TResult> Where<TResult>(IAsyncQuery<TResult> source, Func<TResult, bool> predicate)
Filters an async sequence of values based on a predicate.
static IAsyncLinqQuery<TResult> Where<TResult>(IAsyncQuery<TResult> source, Func<TResult, int, bool> predicate)
Filters an async sequence of values based on a predicate.
static IAsyncLinqQuery<TResult> Where<TResult>(IAsyncQuery<TResult> source, Func<TResult, CancellationToken, Task<bool>> predicate)
Filters an async sequence of values based on a predicate.
static IAsyncLinqQuery<TResult> Where<TResult>(IAsyncQuery<TResult> source, Func<TResult, int, CancellationToken, Task<bool>> predicate)
Filters an async sequence of values based on a predicate.