Exemplo n.º 1
0
        public async Task <PaginationResult <TContract> > PaginateAsync <TEntity, TContract, TSearch>(IQueryable <TEntity> query, TSearch searchObject, PagingInstruction pagingInstruction, Expression <Func <TEntity, bool> > predicate = null, string prefix = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var results    = PaginateInternal(query, searchObject, pagingInstruction, predicate, prefix);
            var totalCount = pagingInstruction.TotalRowCount;
            var data       = await ToListAsync(MapperExtension.ProjectTo <TEntity, TContract>(results.Item2), cancellationToken);

            return(new PaginationResult <TContract>
                   (
                       data,
                       pagingInstruction.PageIndex,
                       pagingInstruction.PageSize,
                       totalCount
                   ));
        }
Exemplo n.º 2
0
        public PaginationResult <TContract> Paginate <TEntity, TContract, TSearch>(IQueryable <TEntity> query, TSearch searchObject, PagingInstruction pagingInstruction, Expression <Func <TEntity, bool> > predicate = null, string prefix = null)
        {
            var results    = PaginateInternal(query, searchObject, pagingInstruction, predicate, prefix);
            var totalCount = pagingInstruction.TotalRowCount;

            var data = MapperExtension
                       .ProjectTo <TEntity, TContract>(results.Item2)
                       .ToList();

            return(new PaginationResult <TContract>
                   (
                       data,
                       pagingInstruction.PageIndex,
                       pagingInstruction.PageSize,
                       totalCount
                   ));
        }