public virtual async Task <GridModel> GetPagedListAsync(IGridExpressionGenerator <TEntity> gridExpressionGenerator, BaseGrid <TEntity> grid, CancellationToken ct)
        {
            var query = DbSet
                        .AsNoTracking()
                        .AsQueryable()
                        .IncludeMany(grid.GetIncludedEntities())
                        .Where(gridExpressionGenerator.GetGridExpression(grid))
                        .Ordered(grid.GetSortedSortingOptions());

            int totalCount = await query.CountAsync(ct);

            var summaries = grid.GetGridSummaries(query);

            query = query
                    .Skip(grid.Pagination.PageSize * (grid.Pagination.PageNumber - 1))
                    .Take(grid.Pagination.PageSize);

            var items = await query.ToListAsync(ct);

            if (!grid.IsGroupable)
            {
                return(new GridModel(summaries, items.Cast <dynamic>().ToImmutableList(), totalCount));
            }

            return(grid.GetGroupedGridItems(items, summaries, totalCount));
        }
Exemple #2
0
 public TemplateService(
     ITemplateUnitOfWork unitOfWork,
     IBaseRepository <TemplateBase> repository,
     IMapper mapper,
     ILogger <TemplateBase> logger,
     IGridExpressionGenerator <TemplateBase> templateGridExpressionGenerator)
     : base(unitOfWork, repository, mapper, logger)
 {
     _templateGridExpressionGenerator = templateGridExpressionGenerator;
 }
 public GameService(IGameUnitOfWork unitOfWork, IMapper mapper, ILogger <GameBase> logger, IGridExpressionGenerator <GameBase> gameGridExpressionGenerator)
     : base(unitOfWork, unitOfWork.GameRepository, mapper, logger)
 {
     _gameGridExpressionGenerator = gameGridExpressionGenerator;
 }