using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Bowin.Common { public class PageList { /// /// 构造函数,当 pageIndex 或 pageSize 为null时,获取全部数据。 /// /// /// 页码,从1开始 /// 页数 public PageList(IQueryable query, int? pageIndex, int? pageSize) { if (pageSize.HasValue && pageIndex.HasValue) { Total = query.Count(); Items = query.Skip((pageIndex.Value - 1) * pageSize.Value).Take(pageSize.Value); } else { Total = query.Count(); Items = query; } } public int Total { get; private set; } public IQueryable Items { get; private set; } } }