public PagedList(PagingCriteria criteria) { PageNumber = criteria.PageNumber; PageSize = criteria.PageSize; PageCount = 1; HasNextPage = false; HasPreviousPage = false; SortBy = criteria.SortBy; SortByDescending = criteria.SortByDescending; }
public PagedList(IQueryable <T> items, PagingCriteria criteria) : base( items .OrderBy( criteria.SortBy, criteria.SortByDescending) .Skip(criteria.PageSize * (criteria.PageNumber - 1)) .Take(criteria.PageSize) .ToList()) { PageNumber = criteria.PageNumber; PageSize = criteria.PageSize; PageCount = (int)Math.Ceiling((decimal)items.Count() / criteria.PageSize); HasNextPage = PageNumber < PageCount; HasPreviousPage = PageNumber > 1; SortBy = criteria.SortBy; SortByDescending = criteria.SortByDescending; }