示例#1
0
 public PagedList(PagingCriteria criteria)
 {
     PageNumber       = criteria.PageNumber;
     PageSize         = criteria.PageSize;
     PageCount        = 1;
     HasNextPage      = false;
     HasPreviousPage  = false;
     SortBy           = criteria.SortBy;
     SortByDescending = criteria.SortByDescending;
 }
示例#2
0
 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;
 }