Exemple #1
0
        public async Task Entities_CountAsync_Predicate_Args()
        {
            const string search = "a";

            //Arrange
            var blog1 = new Blog {
                Name = "blog a", BlogId = 1000
            };
            var blog2 = new Blog {
                Name = "blog b", BlogId = 3000
            };

            _context.Blogs.Add(blog1);
            _context.Blogs.Add(blog2);
            _context.SaveChanges();

            Expression <Func <Blog, bool> > predicate = b => b.Name.Contains(search);

#if EFCORE
            var expected = await EntityFrameworkQueryableExtensions.CountAsync(_context.Blogs, predicate);
#else
            var expected = await QueryableExtensions.CountAsync(_context.Blogs, predicate);
#endif

            //Act
            int result = await(_context.Blogs as IQueryable).CountAsync("Name.Contains(@0)", search);

            //Assert
            Assert.Equal(expected, result);
        }
        public async Task <QueryResult <T> > Query(Func <IQueryable <T>, string, IQueryable <T> > search)
        {
            if (!string.IsNullOrEmpty(Options.Search))
            {
                queryable = search(Queryable, Options.Search);
            }

            dynamic dynamicQueryable = Queryable;

            var totalCount = await EntityFrameworkQueryableExtensions.CountAsync(dynamicQueryable);

            if (totalCount <= ((Options.Page - 1) * Options.PageSize))
            {
                Options.Page = (int)System.Math.Ceiling((decimal)totalCount / Options.PageSize);
                Options.Page = Options.Page == 0
                    ? 1
                    : Options.Page;
            }

            return(new QueryResult <T>
            {
                Page = Options.Page,
                PageSize = Options.PageSize,
                Search = Options.Search,
                TotalCount = totalCount,
                Data = await Queryable
                       .Skip((Options.Page - 1) *Options.PageSize)
                       .Take(Options.PageSize)
                       .ToListAsync()
            });
        }
Exemple #3
0
        public static async Task <PagedList <T> > CreateAsync(IQueryable <T> source, int pageNumber, int pageSize)
        {
            var count = await EntityFrameworkQueryableExtensions.CountAsync <T>(source);

            var items = await source.Skip((pageNumber - 1) *pageSize).Take(pageSize).ToListAsync();

            return(new PagedList <T>(items, count, pageNumber, pageSize));
        }
        public virtual async Task <int> CountAsync(Expression <Func <TEntity, bool> > whereExpression, bool writeDb = false, CancellationToken cancellationToken = default)
        {
            var dbSet = DbContext.Set <TEntity>().AsNoTracking();

            if (writeDb)
            {
                dbSet = dbSet.TagWith(EfCoreConsts.MAXSCALE_ROUTE_TO_MASTER);
            }
            return(await EntityFrameworkQueryableExtensions.CountAsync(dbSet, whereExpression));
        }
        public static Task <int> CountAsync <T>(this IQueryable <T> source)
            where T : class
        {
            if (source is EntitySet <T> )
            {
                source = (source as EntitySet <T>).DbSet;
            }

            return(EntityFrameworkQueryableExtensions.CountAsync(source));
        }
        public virtual async Task <IPagedModel <TEntity> > PagedAsync(int pageIndex, int pageSize, Expression <Func <TEntity, bool> > whereExpression, Expression <Func <TEntity, object> > orderByExpression, bool ascending = false, bool writeDb = false, CancellationToken cancellationToken = default)
        {
            var dbSet = this.GetDbSet(writeDb, false);

            var total = await EntityFrameworkQueryableExtensions.CountAsync(dbSet, whereExpression, cancellationToken);

            if (total == 0)
            {
                return new PagedModel <TEntity>()
                       {
                           PageSize = pageSize
                       }
            }
            ;

            if (pageIndex <= 0)
            {
                pageIndex = 1;
            }

            if (pageSize <= 0)
            {
                pageSize = 10;
            }

            var query = dbSet.Where(whereExpression);

            query = ascending ? query.OrderBy(orderByExpression) : query.OrderByDescending(orderByExpression);
            var data = await EntityFrameworkQueryableExtensions.ToArrayAsync(
                query.Skip((pageIndex - 1) * pageSize).Take(pageSize)
                , cancellationToken);

            return(new PagedModel <TEntity>()
            {
                PageIndex = pageIndex,
                PageSize = pageSize,
                TotalCount = total,
                Data = data
            });
        }
    }
Exemple #7
0
        private async Task <PaginationResult <object> > GetPaginationResult(QueryContainer queryContainer)
        {
            var queryOptions = queryContainer.QueryOptions;
            var queryable    = queryContainer.Queryable;

            dynamic dynamicQueryable = queryable;
            var     totalCount       = await EntityFrameworkQueryableExtensions.CountAsync(dynamicQueryable);

            if (totalCount <= ((queryOptions.Page - 1) * queryOptions.PageSize))
            {
                queryOptions.Page = (int)System.Math.Ceiling((decimal)totalCount / queryOptions.PageSize);
                queryOptions.Page = queryOptions.Page == 0 ? 1 : queryOptions.Page;
            }

            return(new PaginationResult <object>
            {
                Page = queryOptions.Page,
                PageSize = queryOptions.PageSize,
                TotalCount = totalCount,
                Data = await queryable.Cast <object>().Skip((queryOptions.Page - 1) * queryOptions.PageSize).Take(queryOptions.PageSize).ToListAsync()
            });
        }
Exemple #8
0
    public async Task <Result <int> > GetUserActivePromotionCount(int userId)
    {
        DateTime today = DateTime.Today;

        return(Result.Data <int>(await EntityFrameworkQueryableExtensions.CountAsync <Promotion>(_unitOfWork.EntityRepository <Promotion>().GetQueryable((Expression <Func <Promotion, bool> >)((Promotion w) => w.UserId == userId && w.IsActive && w.DueDate >= today), (Func <IQueryable <Promotion>, IOrderedQueryable <Promotion> >)null, Array.Empty <Expression <Func <Promotion, object> > >()), default(CancellationToken))));
    }
Exemple #9
0
 public Task <int> CountAsync <TSource>(IQueryable <TSource> source, Expression <Func <TSource, bool> > predicate, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(EntityFrameworkQueryableExtensions.CountAsync(source, predicate, cancellationToken));
 }
 public async Task <int> CountAsync()
 {
     return(await EntityFrameworkQueryableExtensions.CountAsync(_context.Set <T>()));
 }
Exemple #11
0
 public Task <int> CountAsync <T>(IQueryable <T> query, Expression <Func <T, bool> > predicate)
 {
     return(EntityFrameworkQueryableExtensions.CountAsync(query, predicate));
 }
Exemple #12
0
 /// <summary>
 /// Count asíncrono.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="query"></param>
 /// <returns></returns>
 public static Task <int> CountAsync <T>(this IQueryable <T> query) where T : class
 {
     return(EntityFrameworkQueryableExtensions.CountAsync(query));
 }
Exemple #13
0
        public async Task <int> CountAsync()
        {
            var shardingCounts = await GetGenericMergeEngine(async queryable => await EntityFrameworkQueryableExtensions.CountAsync((IQueryable <T>)queryable));

            return(shardingCounts.Sum());
        }
Exemple #14
0
 public static Task <int> CountAsync <TSource>(this IQueryable <TSource> source)
 {
     return(EntityFrameworkQueryableExtensions.CountAsync(source));
 }
 public Task <int> CountAsync <TSource>(
     IQueryable <TSource> source,
     CancellationToken cancellationToken = default) =>
 EntityFrameworkQueryableExtensions.CountAsync(source, cancellationToken);
        private async Task <int> GetCountAsync(IQueryable newSource)
        {
            var results = await GetStatisDataAsync <int>(x => EntityFrameworkQueryableExtensions.CountAsync((dynamic)x), newSource);

            return(results.Sum());
        }
 public Task <int> CountAsync <T>(IQueryable <T> query)
 {
     return(EntityFrameworkQueryableExtensions.CountAsync(query));
 }
Exemple #18
0
 public static Task <int> CountAsync <TEntity>(this IQueryable <TEntity> query)
 {
     return(EntityFrameworkQueryableExtensions.CountAsync(query));
 }
Exemple #19
0
 /// <inheritdoc cref="EntityFrameworkQueryableExtensions.CountAsync{TSource}(IQueryable{TSource}, Expression{Func{TSource, bool}}, CancellationToken)"/>
 public Task <int> CountAsync <TSource>(
     IQueryable <TSource> source,
     Expression <Func <TSource, bool> > predicate,
     CancellationToken token)
 => EntityFrameworkQueryableExtensions.CountAsync(source, predicate, token);
        public async Task Extension_methods_validate_arguments()
        {
            // ReSharper disable AssignNullToNotNullAttribute

            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().FirstAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstOrDefaultAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstOrDefaultAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().FirstOrDefaultAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().SingleAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleOrDefaultAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleOrDefaultAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().SingleOrDefaultAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.ContainsAsync(null, 1));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.ContainsAsync(null, 1, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AnyAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AnyAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().AnyAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AllAsync <int>(null, s => true));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AllAsync <int>(null, s => true, new CancellationToken()));
            await ArgumentNullTest("predicate", () => Source().AllAsync(null));
            await ArgumentNullTest("predicate", () => Source().AllAsync(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.CountAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.CountAsync <int>(null, s => true));
            await ArgumentNullTest("predicate", () => Source().CountAsync(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync <int>(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync <int>(null, s => true));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync <int>(null, s => true, new CancellationToken()));
            await ArgumentNullTest("predicate", () => Source().LongCountAsync(null));
            await ArgumentNullTest("predicate", () => Source().LongCountAsync(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync <int>(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync <int, bool>(null, s => true));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync <int, bool>(null, s => true, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source().MinAsync <int, bool>(null));
            await ArgumentNullTest("selector", () => Source().MinAsync <int, bool>(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync <int>(null));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync <int>(null, new CancellationToken()));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync <int, bool>(null, s => true));
            await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync <int, bool>(null, s => true, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source().MaxAsync <int, bool>(null));
            await ArgumentNullTest("selector", () => Source().MaxAsync <int, bool>(null, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).SumAsync());
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).SumAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).SumAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <int>().SumAsync((Expression <Func <int, int> >)null));
            await ArgumentNullTest("selector", () => Source <int?>().SumAsync((Expression <Func <int?, int> >)null));
            await ArgumentNullTest("selector", () => Source <long>().SumAsync((Expression <Func <long, int> >)null));
            await ArgumentNullTest("selector", () => Source <long?>().SumAsync((Expression <Func <long?, int> >)null));
            await ArgumentNullTest("selector", () => Source <float>().SumAsync((Expression <Func <float, int> >)null));
            await ArgumentNullTest("selector", () => Source <float?>().SumAsync((Expression <Func <float?, int> >)null));
            await ArgumentNullTest("selector", () => Source <double>().SumAsync((Expression <Func <double, int> >)null));
            await ArgumentNullTest("selector", () => Source <double?>().SumAsync((Expression <Func <double?, int> >)null));
            await ArgumentNullTest("selector", () => Source <decimal>().SumAsync((Expression <Func <decimal, int> >)null));
            await ArgumentNullTest("selector", () => Source <decimal?>().SumAsync((Expression <Func <decimal?, int> >)null));
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).AverageAsync());
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).AverageAsync(new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <int>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <int?>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <long>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <long?>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <float>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <float?>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <double>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <double?>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <decimal>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).AverageAsync(i => 0));
            await ArgumentNullTest("source", () => ((IQueryable <decimal?>)null).AverageAsync(i => 0, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <int>().AverageAsync((Expression <Func <int, int> >)null));
            await ArgumentNullTest("selector", () => Source <int>().AverageAsync((Expression <Func <int, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <int?>().AverageAsync((Expression <Func <int?, int> >)null));
            await ArgumentNullTest("selector", () => Source <int?>().AverageAsync((Expression <Func <int?, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <long>().AverageAsync((Expression <Func <long, int> >)null));
            await ArgumentNullTest("selector", () => Source <long>().AverageAsync((Expression <Func <long, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <long?>().AverageAsync((Expression <Func <long?, int> >)null));
            await ArgumentNullTest("selector", () => Source <long?>().AverageAsync((Expression <Func <long?, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <float>().AverageAsync((Expression <Func <float, int> >)null));
            await ArgumentNullTest("selector", () => Source <float>().AverageAsync((Expression <Func <float, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <float?>().AverageAsync((Expression <Func <float?, int> >)null));
            await ArgumentNullTest("selector", () => Source <float?>().AverageAsync((Expression <Func <float?, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <double>().AverageAsync((Expression <Func <double, int> >)null));
            await ArgumentNullTest("selector", () => Source <double>().AverageAsync((Expression <Func <double, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <double?>().AverageAsync((Expression <Func <double?, int> >)null));
            await ArgumentNullTest("selector", () => Source <double?>().AverageAsync((Expression <Func <double?, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <decimal>().AverageAsync((Expression <Func <decimal, int> >)null));
            await ArgumentNullTest("selector", () => Source <decimal>().AverageAsync((Expression <Func <decimal, int> >)null, new CancellationToken()));
            await ArgumentNullTest("selector", () => Source <decimal?>().AverageAsync((Expression <Func <decimal?, int> >)null));
            await ArgumentNullTest("selector", () => Source <decimal?>().AverageAsync((Expression <Func <decimal?, int> >)null, new CancellationToken()));

            // ReSharper restore AssignNullToNotNullAttribute
        }
Exemple #21
0
 /// <inheritdoc cref="EntityFrameworkQueryableExtensions.CountAsync{TSource}(IQueryable{TSource}, Expression{Func{TSource, bool}}, CancellationToken)"/>
 public static Task <int> CountAsyncEF <TSource>(
     this IQueryable <TSource> source,
     Expression <Func <TSource, bool> > predicate,
     CancellationToken cancellationToken = default)
 => EntityFrameworkQueryableExtensions.CountAsync(source, predicate, cancellationToken);
 public virtual async Task <int> CountTotalAsync()
 {
     return(await EntityFrameworkQueryableExtensions.CountAsync(_dbContext.Set <T>()));
 }
Exemple #23
0
 public static Task <int> CountAsyncEF <TSource>(
     this IQueryable <TSource> source,
     CancellationToken token = default)
 => EntityFrameworkQueryableExtensions.CountAsync(source, token);