コード例 #1
0
 /// <summary>
 /// 实例化,获得实体,获得页数,获得分页属性
 /// </summary>
 /// <param name="initentity">将要分页的实体类</param>
 public PageSpreadHelper(IQueryable <T> initentity, int pagesize)
 {
     this.Enity      = initentity.ToList();
     this.TotalCount = this.Enity.Count();
     this.PageSize   = pagesize;
     this.PageCount  = PageSpreadHelper <T> .GetPageCount(this.Enity.Count(), this.PageSize);
 }
コード例 #2
0
        //获取分页数据
        /// <summary>
        /// 将数据跳页后返回需求页码的那部分数据(外链版本)
        /// </summary>
        /// <param name="result">原始大数据</param>
        /// <param name="pageIndex">跳到第几页</param>
        /// <param name="recordCount">数据总条数</param>
        /// /// <param name="pagesize">分页每页数据数</param>
        /// <returns></returns>
        public static List <T1> GetPagedDataSource <T1>(List <T1> ent, int pageIndex, int recordCount, int pagesize)
        {
            var pageCount = PageSpreadHelper <T1> .GetPageCount(recordCount, pagesize);

            if (pageIndex >= pageCount && pageCount >= 1)
            {
                pageIndex = pageCount - 1;
            }
            List <T1> return_list = ent.Skip(pageIndex * pagesize).Take(pagesize).ToList();

            return(return_list);
        }