Answer the question
In order to leave comments, you need to log in
How to make offset restrictions for pagination?
The repository has a method that accepts an offset and a limit:
public async Task<IList<TEntity>> GetAllPaged(int offset, int limit)
{
return await _context.Set<TEntity>()
.OrderBy(property => property.Id)
.Skip(offset)
.Take(limit)
.ToListAsync();
}
public async Task<IList<ProductDto>> GetPageAllAsync(PaginationFilterDto paginationFilter)
{
int skip = (paginationFilter.PageNumber - 1) * paginationFilter.PageSize;
int total = await _unitOfWork.ProductRepository.GetQuantity();
IList<Product> productsPaged = await _unitOfWork.ProductRepository.GetAllPaged(skip, paginationFilter.PageSize);
return _mapper.Map<IList<ProductDto>>(productsPaged);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question