Beispiel #1
0
 public Task <Dictionary <TKey, TSource> > ToDictionaryAsync <TSource, TKey>(
     IQueryable <TSource> source,
     Func <TSource, TKey> keySelector,
     IEqualityComparer <TKey> comparer,
     CancellationToken cancellationToken = default)
     where TKey : notnull =>
 EntityFrameworkQueryableExtensions.ToDictionaryAsync(source, keySelector, comparer, cancellationToken);
Beispiel #2
0
 /// <inheritdoc cref="EntityFrameworkQueryableExtensions.ToDictionaryAsync{TSource, TKey, TElement}(IQueryable{TSource}, Func{TSource, TKey}, Func{TSource, TElement}, IEqualityComparer{TKey}, CancellationToken)"/>
 public static Task <Dictionary <TKey, TElement> > ToDictionaryAsyncEF <TSource, TKey, TElement>(
     this IQueryable <TSource> source,
     Func <TSource, TKey> keySelector,
     Func <TSource, TElement> elementSelector,
     IEqualityComparer <TKey> comparer,
     CancellationToken cancellationToken = default)
 => EntityFrameworkQueryableExtensions.ToDictionaryAsync(source, keySelector, elementSelector, comparer, cancellationToken);
Beispiel #3
0
 /// <inheritdoc cref="EntityFrameworkQueryableExtensions.ToDictionaryAsync{TSource, TKey, TElement}(IQueryable{TSource}, Func{TSource, TKey}, Func{TSource, TElement}, CancellationToken)"/>
 public Task <Dictionary <TKey, TElement> > ToDictionaryAsync <TSource, TKey, TElement>(
     IQueryable <TSource> source,
     Func <TSource, TKey> keySelector,
     Func <TSource, TElement> elementSelector,
     CancellationToken token)
     where TKey : notnull
 => EntityFrameworkQueryableExtensions.ToDictionaryAsync(source, keySelector, elementSelector, token);
        public async Task TestAsyncMethods([Values(true, false)] bool enableFilter)
        {
            using (var ctx = CreateContext(enableFilter))
            {
                var query = ctx.Products.AsQueryable().Where(p => p.ProductName.Contains("a"));

                var expectedArray = await query.ToArrayAsync();

                var expectedDictionary = await query.ToDictionaryAsync(p => p.ProductId);

                var expectedAny = await query.AnyAsync();

                var byList = await EntityFrameworkQueryableExtensions.ToListAsync(query.ToLinqToDB());

                var byArray = await EntityFrameworkQueryableExtensions.ToArrayAsync(query.ToLinqToDB());

                var byDictionary = await EntityFrameworkQueryableExtensions.ToDictionaryAsync(query.ToLinqToDB(), p => p.ProductId);

                var any = await EntityFrameworkQueryableExtensions.AnyAsync(query.ToLinqToDB());
            }
        }
Beispiel #5
0
        public async Task TestAsyncMethods()
        {
            using (var ctx = CreateAdventureWorksContext())
            {
                var query = ctx.Products.AsQueryable().Where(p => p.Name.Contains("a"));

                var expected = await query.ToArrayAsync();

                var expectedDictionary = await query.ToDictionaryAsync(p => p.ProductID);

                var expectedAny = await query.AnyAsync();

                var byList = await EntityFrameworkQueryableExtensions.ToListAsync(query.ToLinqToDB());

                var byArray = await EntityFrameworkQueryableExtensions.ToArrayAsync(query.ToLinqToDB());

                var byDictionary = await EntityFrameworkQueryableExtensions.ToDictionaryAsync(query.ToLinqToDB(), p => p.ProductID);

                var any = await EntityFrameworkQueryableExtensions.AnyAsync(query.ToLinqToDB());
            }
        }
Beispiel #6
0
 public Task <Dictionary <TKey, TElement> > ToDictionaryAsync <TSource, TKey, TElement>(IQueryable <TSource> source, Func <TSource, TKey> keySelector, Func <TSource, TElement> elementSelector, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(EntityFrameworkQueryableExtensions.ToDictionaryAsync(source, keySelector, elementSelector, cancellationToken));
 }
 public Task <Dictionary <TKey, TSource> > ToDictionaryAsync <TSource, TKey>(
     IQueryable <TSource> source,
     Func <TSource, TKey> keySelector,
     CancellationToken cancellationToken = default) =>
 EntityFrameworkQueryableExtensions.ToDictionaryAsync(source, keySelector, cancellationToken);
Beispiel #8
0
 public Task <Dictionary <TKey, TElement> > ToDictionaryAsync <T, TKey, TElement>(IQueryable <T> query, Func <T, TKey> keySelector, Func <T, TElement> elementSelector)
 {
     return(EntityFrameworkQueryableExtensions.ToDictionaryAsync(query, keySelector, elementSelector));
 }