Class AsyncExtensions
- Namespace
- LinqToDB
- Assembly
- linq2db.dll
Provides helper methods for asynchronous operations.
public static class AsyncExtensions
- Inheritance
-
AsyncExtensions
Methods
AllAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)
public static Task<bool> AllAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken token = default)
Parameters
source
IQueryable<TSource>predicate
Expression<Func<TSource, bool>>token
CancellationToken
Returns
Type Parameters
TSource
AnyAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)
public static Task<bool> AnyAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken token = default)
Parameters
source
IQueryable<TSource>predicate
Expression<Func<TSource, bool>>token
CancellationToken
Returns
Type Parameters
TSource
AnyAsync<TSource>(IQueryable<TSource>, CancellationToken)
public static Task<bool> AnyAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>token
CancellationToken
Returns
Type Parameters
TSource
AsAsyncEnumerable<TSource>(IQueryable<TSource>)
Returns an IAsyncEnumerable<T> that can be enumerated asynchronously.
public static IAsyncEnumerable<TSource> AsAsyncEnumerable<TSource>(this IQueryable<TSource> source)
Parameters
source
IQueryable<TSource>Source sequence.
Returns
- IAsyncEnumerable<TSource>
A query that can be enumerated asynchronously.
Type Parameters
TSource
Source sequence element type.
AverageAsync(IQueryable<decimal>, CancellationToken)
public static Task<decimal> AverageAsync(this IQueryable<decimal> source, CancellationToken token = default)
Parameters
source
IQueryable<decimal>token
CancellationToken
Returns
AverageAsync(IQueryable<double>, CancellationToken)
public static Task<double> AverageAsync(this IQueryable<double> source, CancellationToken token = default)
Parameters
source
IQueryable<double>token
CancellationToken
Returns
AverageAsync(IQueryable<int>, CancellationToken)
public static Task<double> AverageAsync(this IQueryable<int> source, CancellationToken token = default)
Parameters
source
IQueryable<int>token
CancellationToken
Returns
AverageAsync(IQueryable<long>, CancellationToken)
public static Task<double> AverageAsync(this IQueryable<long> source, CancellationToken token = default)
Parameters
source
IQueryable<long>token
CancellationToken
Returns
AverageAsync(IQueryable<decimal?>, CancellationToken)
public static Task<decimal?> AverageAsync(this IQueryable<decimal?> source, CancellationToken token = default)
Parameters
source
IQueryable<decimal?>token
CancellationToken
Returns
AverageAsync(IQueryable<double?>, CancellationToken)
public static Task<double?> AverageAsync(this IQueryable<double?> source, CancellationToken token = default)
Parameters
source
IQueryable<double?>token
CancellationToken
Returns
AverageAsync(IQueryable<int?>, CancellationToken)
public static Task<double?> AverageAsync(this IQueryable<int?> source, CancellationToken token = default)
Parameters
source
IQueryable<int?>token
CancellationToken
Returns
AverageAsync(IQueryable<long?>, CancellationToken)
public static Task<double?> AverageAsync(this IQueryable<long?> source, CancellationToken token = default)
Parameters
source
IQueryable<long?>token
CancellationToken
Returns
AverageAsync(IQueryable<float?>, CancellationToken)
public static Task<float?> AverageAsync(this IQueryable<float?> source, CancellationToken token = default)
Parameters
source
IQueryable<float?>token
CancellationToken
Returns
AverageAsync(IQueryable<float>, CancellationToken)
public static Task<float> AverageAsync(this IQueryable<float> source, CancellationToken token = default)
Parameters
source
IQueryable<float>token
CancellationToken
Returns
AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, decimal>>, CancellationToken)
public static Task<decimal> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, decimal>>token
CancellationToken
Returns
Type Parameters
TSource
AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, double>>, CancellationToken)
public static Task<double> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, double>>token
CancellationToken
Returns
Type Parameters
TSource
AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, int>>, CancellationToken)
public static Task<double> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, int>>token
CancellationToken
Returns
Type Parameters
TSource
AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, long>>, CancellationToken)
public static Task<double> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, long>>token
CancellationToken
Returns
Type Parameters
TSource
AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, decimal?>>, CancellationToken)
public static Task<decimal?> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, decimal?>>token
CancellationToken
Returns
Type Parameters
TSource
AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, double?>>, CancellationToken)
public static Task<double?> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double?>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, double?>>token
CancellationToken
Returns
Type Parameters
TSource
AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, int?>>, CancellationToken)
public static Task<double?> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int?>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, int?>>token
CancellationToken
Returns
Type Parameters
TSource
AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, long?>>, CancellationToken)
public static Task<double?> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long?>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, long?>>token
CancellationToken
Returns
Type Parameters
TSource
AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, float?>>, CancellationToken)
public static Task<float?> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float?>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, float?>>token
CancellationToken
Returns
Type Parameters
TSource
AverageAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, float>>, CancellationToken)
public static Task<float> AverageAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, float>>token
CancellationToken
Returns
Type Parameters
TSource
ContainsAsync<TSource>(IQueryable<TSource>, TSource, CancellationToken)
public static Task<bool> ContainsAsync<TSource>(this IQueryable<TSource> source, TSource item, CancellationToken token = default)
Parameters
source
IQueryable<TSource>item
TSourcetoken
CancellationToken
Returns
Type Parameters
TSource
CountAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)
public static Task<int> CountAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken token = default)
Parameters
source
IQueryable<TSource>predicate
Expression<Func<TSource, bool>>token
CancellationToken
Returns
Type Parameters
TSource
CountAsync<TSource>(IQueryable<TSource>, CancellationToken)
public static Task<int> CountAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>token
CancellationToken
Returns
Type Parameters
TSource
FirstAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)
public static Task<TSource> FirstAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken token = default)
Parameters
source
IQueryable<TSource>predicate
Expression<Func<TSource, bool>>token
CancellationToken
Returns
- Task<TSource>
Type Parameters
TSource
FirstAsync<TSource>(IQueryable<TSource>, CancellationToken)
public static Task<TSource> FirstAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>token
CancellationToken
Returns
- Task<TSource>
Type Parameters
TSource
FirstOrDefaultAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)
public static Task<TSource?> FirstOrDefaultAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken token = default)
Parameters
source
IQueryable<TSource>predicate
Expression<Func<TSource, bool>>token
CancellationToken
Returns
- Task<TSource>
Type Parameters
TSource
FirstOrDefaultAsync<TSource>(IQueryable<TSource>, CancellationToken)
public static Task<TSource?> FirstOrDefaultAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>token
CancellationToken
Returns
- Task<TSource>
Type Parameters
TSource
ForEachAsync<TSource>(IQueryable<TSource>, Action<TSource>, CancellationToken)
Asynchronously apply provided action to each element in source sequence. Sequence elements processed sequentially.
public static Task ForEachAsync<TSource>(this IQueryable<TSource> source, Action<TSource> action, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source sequence.
action
Action<TSource>Action to apply to each sequence element.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task
Asynchronous operation completion task.
Type Parameters
TSource
Source sequence element type.
ForEachUntilAsync<TSource>(IQueryable<TSource>, Func<TSource, bool>, CancellationToken)
Asynchronously apply provided function to each element in source sequence sequentially.
Sequence enumeration stops if function returns false
.
public static Task ForEachUntilAsync<TSource>(this IQueryable<TSource> source, Func<TSource, bool> func, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source sequence.
func
Func<TSource, bool>Function to apply to each sequence element. Returning
false
from function will stop numeration.token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task
Asynchronous operation completion task.
Type Parameters
TSource
Source sequence element type.
LongCountAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)
public static Task<long> LongCountAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken token = default)
Parameters
source
IQueryable<TSource>predicate
Expression<Func<TSource, bool>>token
CancellationToken
Returns
Type Parameters
TSource
LongCountAsync<TSource>(IQueryable<TSource>, CancellationToken)
public static Task<long> LongCountAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>token
CancellationToken
Returns
Type Parameters
TSource
MaxAsync<TSource>(IQueryable<TSource>, CancellationToken)
public static Task<TSource?> MaxAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>token
CancellationToken
Returns
- Task<TSource>
Type Parameters
TSource
MaxAsync<TSource, TResult>(IQueryable<TSource>, Expression<Func<TSource, TResult>>, CancellationToken)
public static Task<TResult?> MaxAsync<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, TResult>>token
CancellationToken
Returns
- Task<TResult>
Type Parameters
TSource
TResult
MinAsync<TSource>(IQueryable<TSource>, CancellationToken)
public static Task<TSource?> MinAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>token
CancellationToken
Returns
- Task<TSource>
Type Parameters
TSource
MinAsync<TSource, TResult>(IQueryable<TSource>, Expression<Func<TSource, TResult>>, CancellationToken)
public static Task<TResult?> MinAsync<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, TResult>>token
CancellationToken
Returns
- Task<TResult>
Type Parameters
TSource
TResult
SingleAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)
public static Task<TSource> SingleAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken token = default)
Parameters
source
IQueryable<TSource>predicate
Expression<Func<TSource, bool>>token
CancellationToken
Returns
- Task<TSource>
Type Parameters
TSource
SingleAsync<TSource>(IQueryable<TSource>, CancellationToken)
public static Task<TSource> SingleAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>token
CancellationToken
Returns
- Task<TSource>
Type Parameters
TSource
SingleOrDefaultAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)
public static Task<TSource?> SingleOrDefaultAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken token = default)
Parameters
source
IQueryable<TSource>predicate
Expression<Func<TSource, bool>>token
CancellationToken
Returns
- Task<TSource>
Type Parameters
TSource
SingleOrDefaultAsync<TSource>(IQueryable<TSource>, CancellationToken)
public static Task<TSource?> SingleOrDefaultAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>token
CancellationToken
Returns
- Task<TSource>
Type Parameters
TSource
SumAsync(IQueryable<decimal>, CancellationToken)
public static Task<decimal> SumAsync(this IQueryable<decimal> source, CancellationToken token = default)
Parameters
source
IQueryable<decimal>token
CancellationToken
Returns
SumAsync(IQueryable<double>, CancellationToken)
public static Task<double> SumAsync(this IQueryable<double> source, CancellationToken token = default)
Parameters
source
IQueryable<double>token
CancellationToken
Returns
SumAsync(IQueryable<int>, CancellationToken)
public static Task<int> SumAsync(this IQueryable<int> source, CancellationToken token = default)
Parameters
source
IQueryable<int>token
CancellationToken
Returns
SumAsync(IQueryable<long>, CancellationToken)
public static Task<long> SumAsync(this IQueryable<long> source, CancellationToken token = default)
Parameters
source
IQueryable<long>token
CancellationToken
Returns
SumAsync(IQueryable<decimal?>, CancellationToken)
public static Task<decimal?> SumAsync(this IQueryable<decimal?> source, CancellationToken token = default)
Parameters
source
IQueryable<decimal?>token
CancellationToken
Returns
SumAsync(IQueryable<double?>, CancellationToken)
public static Task<double?> SumAsync(this IQueryable<double?> source, CancellationToken token = default)
Parameters
source
IQueryable<double?>token
CancellationToken
Returns
SumAsync(IQueryable<int?>, CancellationToken)
public static Task<int?> SumAsync(this IQueryable<int?> source, CancellationToken token = default)
Parameters
source
IQueryable<int?>token
CancellationToken
Returns
SumAsync(IQueryable<long?>, CancellationToken)
public static Task<long?> SumAsync(this IQueryable<long?> source, CancellationToken token = default)
Parameters
source
IQueryable<long?>token
CancellationToken
Returns
SumAsync(IQueryable<float?>, CancellationToken)
public static Task<float?> SumAsync(this IQueryable<float?> source, CancellationToken token = default)
Parameters
source
IQueryable<float?>token
CancellationToken
Returns
SumAsync(IQueryable<float>, CancellationToken)
public static Task<float> SumAsync(this IQueryable<float> source, CancellationToken token = default)
Parameters
source
IQueryable<float>token
CancellationToken
Returns
SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, decimal>>, CancellationToken)
public static Task<decimal> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, decimal>>token
CancellationToken
Returns
Type Parameters
TSource
SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, double>>, CancellationToken)
public static Task<double> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, double>>token
CancellationToken
Returns
Type Parameters
TSource
SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, int>>, CancellationToken)
public static Task<int> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, int>>token
CancellationToken
Returns
Type Parameters
TSource
SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, long>>, CancellationToken)
public static Task<long> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, long>>token
CancellationToken
Returns
Type Parameters
TSource
SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, decimal?>>, CancellationToken)
public static Task<decimal?> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, decimal?>>token
CancellationToken
Returns
Type Parameters
TSource
SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, double?>>, CancellationToken)
public static Task<double?> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, double?>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, double?>>token
CancellationToken
Returns
Type Parameters
TSource
SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, int?>>, CancellationToken)
public static Task<int?> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int?>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, int?>>token
CancellationToken
Returns
Type Parameters
TSource
SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, long?>>, CancellationToken)
public static Task<long?> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, long?>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, long?>>token
CancellationToken
Returns
Type Parameters
TSource
SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, float?>>, CancellationToken)
public static Task<float?> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float?>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, float?>>token
CancellationToken
Returns
Type Parameters
TSource
SumAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, float>>, CancellationToken)
public static Task<float> SumAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, float>> selector, CancellationToken token = default)
Parameters
source
IQueryable<TSource>selector
Expression<Func<TSource, float>>token
CancellationToken
Returns
Type Parameters
TSource
ToArrayAsync<TSource>(IQueryable<TSource>, CancellationToken)
Asynchronously loads data from query to an array.
public static Task<TSource[]> ToArrayAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<TSource[]>
Array with query results.
Type Parameters
TSource
Query element type.
ToDictionaryAsync<TSource, TKey>(IQueryable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>, CancellationToken)
Asynchronously loads data from query to a dictionary.
public static Task<Dictionary<TKey, TSource>> ToDictionaryAsync<TSource, TKey>(this IQueryable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, CancellationToken token = default) where TKey : notnull
Parameters
source
IQueryable<TSource>Source query.
keySelector
Func<TSource, TKey>Source element key selector.
comparer
IEqualityComparer<TKey>Dictionary key comparer.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<Dictionary<TKey, TSource>>
Dictionary with query results.
Type Parameters
TSource
Query element type.
TKey
Dictionary key type.
ToDictionaryAsync<TSource, TKey>(IQueryable<TSource>, Func<TSource, TKey>, CancellationToken)
Asynchronously loads data from query to a dictionary.
public static Task<Dictionary<TKey, TSource>> ToDictionaryAsync<TSource, TKey>(this IQueryable<TSource> source, Func<TSource, TKey> keySelector, CancellationToken token = default) where TKey : notnull
Parameters
source
IQueryable<TSource>Source query.
keySelector
Func<TSource, TKey>Source element key selector.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<Dictionary<TKey, TSource>>
Dictionary with query results.
Type Parameters
TSource
Query element type.
TKey
Dictionary key type.
ToDictionaryAsync<TSource, TKey, TElement>(IQueryable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, IEqualityComparer<TKey>, CancellationToken)
Asynchronously loads data from query to a dictionary.
public static Task<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, TKey, TElement>(this IQueryable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer, CancellationToken token = default) where TKey : notnull
Parameters
source
IQueryable<TSource>Source query.
keySelector
Func<TSource, TKey>Source element key selector.
elementSelector
Func<TSource, TElement>Dictionary element selector.
comparer
IEqualityComparer<TKey>Dictionary key comparer.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<Dictionary<TKey, TElement>>
Dictionary with query results.
Type Parameters
TSource
Query element type.
TKey
Dictionary key type.
TElement
Dictionary element type.
ToDictionaryAsync<TSource, TKey, TElement>(IQueryable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, CancellationToken)
Asynchronously loads data from query to a dictionary.
public static Task<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, TKey, TElement>(this IQueryable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, CancellationToken token = default) where TKey : notnull
Parameters
source
IQueryable<TSource>Source query.
keySelector
Func<TSource, TKey>Source element key selector.
elementSelector
Func<TSource, TElement>Dictionary element selector.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
- Task<Dictionary<TKey, TElement>>
Dictionary with query results.
Type Parameters
TSource
Query element type.
TKey
Dictionary key type.
TElement
Dictionary element type.
ToListAsync<TSource>(IQueryable<TSource>, CancellationToken)
Asynchronously loads data from query to a list.
public static Task<List<TSource>> ToListAsync<TSource>(this IQueryable<TSource> source, CancellationToken token = default)
Parameters
source
IQueryable<TSource>Source query.
token
CancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TSource
Query element type.