Пример #1
0
 /// <summary>
 /// Asynchronously loads data from query to a dictionary
 /// </summary>
 /// <typeparam name="TSource">Query element type</typeparam>
 /// <typeparam name="TKey">Dictionary key type</typeparam>
 /// <param name="source">Source query</param>
 /// <param name="keySelector">Source element key selector</param>
 /// <param name="comparer">Dictionary key comparer</param>
 /// <returns>Dictionary with query results</returns>
 public static Task <Dictionary <TKey, TSource> > ToDictionaryAsync <TSource, TKey>(this IQueryable <TSource> source,
                                                                                    Func <TSource, TKey> keySelector, IEqualityComparer <TKey> comparer = null) where TKey : notnull
 {
     return(comparer == null
         ? AsyncExtensions.ToDictionaryAsync(source, keySelector)
         : AsyncExtensions.ToDictionaryAsync(source, keySelector, comparer));
 }
 /// <summary>
 /// Asynchronously loads data from query to a dictionary.
 /// </summary>
 /// <typeparam name="TSource">Query element type.</typeparam>
 /// <typeparam name="TKey">Dictionary key type.</typeparam>
 /// <typeparam name="TElement">Dictionary element type.</typeparam>
 /// <param name="source">Source query.</param>
 /// <param name="keySelector">Source element key selector.</param>
 /// <param name="elementSelector">Dictionary element selector.</param>
 /// <param name="comparer">Dictionary key comparer.</param>
 /// <param name="token">Optional asynchronous operation cancellation token.</param>
 /// <returns>Dictionary with query results.</returns>
 public static Task <Dictionary <TKey, TElement> > ToDictionaryAsyncLinqToDB <TSource, TKey, TElement>(
     this IQueryable <TSource> source,
     Func <TSource, TKey> keySelector,
     Func <TSource, TElement> elementSelector,
     IEqualityComparer <TKey> comparer,
     CancellationToken token = default)
 => AsyncExtensions.ToDictionaryAsync(source.ToLinqToDB(), keySelector, elementSelector, comparer, token);
Пример #3
0
 /// <inheritdoc cref="AsyncExtensions.ToDictionaryAsync{TSource, TKey, TElement}(IQueryable{TSource}, Func{TSource, TKey}, Func{TSource, TElement}, CancellationToken)"/>
 public static Task <Dictionary <TKey, TElement> > ToDictionaryAsyncLinqToDB <TSource, TKey, TElement>(
     this IQueryable <TSource> source,
     Func <TSource, TKey> keySelector,
     Func <TSource, TElement> elementSelector,
     CancellationToken token = default)
     where TKey : notnull
 => AsyncExtensions.ToDictionaryAsync(source.ToLinqToDB(), keySelector, elementSelector, token);