public async Task <IPagedListResult <TEntity> > GetAsPagedListAsync(IPagedListRequest <TEntity> pagedListRequest, Expression <Func <TEntity, bool> > filter = null, string includeProperties = null) { if (filter != null) { pagedListRequest.SetFilters(filter, out filter); } AddInterceptFilters(filter, out filter); if (pagedListRequest.PageNumber == 0) { pagedListRequest.PageNumber = 1; } if (pagedListRequest.PageSize == 0) { pagedListRequest.PageSize = ApplicationSettings.Pagination.PageSize; } //pageNumber is 1 indexed. so We for the first items to fetch we need to compute it from zero. var skip = pagedListRequest.PageSize * (pagedListRequest.PageNumber - 1); var take = pagedListRequest.PageSize; var count = await GetQueryable(filter).CountAsync(); if (pagedListRequest.Order.IsPopulated()) { return(await GetQueryable(filter, null, includeProperties, skip, take).OrderBy(pagedListRequest.Order).ToPagedListAsync(count)); } return(await GetQueryable(filter, null, includeProperties, skip, take).ToPagedListAsync(count)); }
public async Task <IPagedListResult <TEntity> > GetAsPagedListAsync(IPagedListRequest <TEntity> pagedListRequest, Expression <Func <TEntity, bool> > filter = null, string includeProperties = null) { if (filter != null) { pagedListRequest.SetFilters(filter, out filter); } AddInterceptFilters(filter, out filter); if (pagedListRequest.PageNumber == 0) { pagedListRequest.PageNumber = 1; } if (pagedListRequest.PageSize == 0) { pagedListRequest.PageSize = 20; } //pageNumber is 1 indexed. so we do a -1. var skip = pagedListRequest.PageSize * (pagedListRequest.PageNumber - 1); var take = pagedListRequest.PageSize; var count = await GetQueryable(filter).CountAsync(); if (pagedListRequest.Order.IsPopulated()) { return(await GetQueryable(filter, null, includeProperties, skip, take).OrderBy(pagedListRequest.Order).ToPagedListAsync(count)); } return(await GetQueryable(filter, null, includeProperties, skip, take).ToPagedListAsync(count)); }
public async Task <PagedListResult <TariffDto> > GetTariffList(IPagedListRequest <Eron.Core.Entities.Financial.Order.Tariff> input) { var result = (await UnitOfWork.TariffRepository.GetAsPagedListAsync(input)).MapTo <PagedListResult <TariffDto> >(); var tariffPriceList = await UnitOfWork.TariffPriceRepository.GetAllValidAsync(); foreach (var item in result.Result) { item.TariffPrice = tariffPriceList.FirstOrDefault(x => x.TariffId == item.Id)?.Price; } return(result); }
public IPagedListResult <TEntity> GetAsPagedList(IPagedListRequest <TEntity> pagedListRequest, Expression <Func <TEntity, bool> > filter = null, string includeProperties = null) { //pageNumber is 1 indexed. so We for the first items to fetch we need to compute it from zero. var skip = pagedListRequest.PageSize * (pagedListRequest.PageNumber - 1); var take = pagedListRequest.PageSize; pagedListRequest.SetFilters(filter, out filter); AddInterceptFilters(filter, out filter); var count = GetQueryable(filter).Count(); if (pagedListRequest.Order.IsPopulated()) { return(GetQueryable(filter, null, includeProperties).OrderBy(pagedListRequest.Order).Skip(skip).Take(take).ToPagedList(count)); } return(GetQueryable(filter, null, includeProperties, skip, take).ToPagedList(count)); }
public virtual async Task <IList <TEntity> > GetPagedListAsync(Expression <Func <TEntity, bool> > predicate, IDictionary <Expression <Func <TEntity, object> >, bool> dictOrder, IPagedListRequest request, CancellationToken cancellationToken = default) { return(await GetPagedList(predicate, dictOrder, request).ToListAsync(cancellationToken)); }
public virtual IList <TEntity> GetPagedList(Expression <Func <TEntity, bool> > predicate, IDictionary <Expression <Func <TEntity, object> >, bool> dictOrder, IPagedListRequest request, out int totalCount) { var query = GetNoTrackingQueryable(predicate); query = query.ApplyOrder(dictOrder); totalCount = query.Count(); return(query.Skip(request.Skip).Take(request.PageSize).ToList()); }
public void SetPageIndexAndPageSize(IPagedListRequest request) { this.PageIndex = request.PageIndex; this.PageSize = request.PageSize; }