首页 > 代码库 > 自定义分页
自定义分页
using System; using System.Collections.Generic; using System.Linq; using Water; namespace Water.Helper { public class PagedList<T> : List<T> { /// <summary> /// 页索引 /// </summary> public int PageIndex { get; private set; } /// <summary> /// 页大小 /// </summary> public int PageSize { get; private set; } /// <summary> /// 总数据条数 /// </summary> public int TotalCount { get; private set; } /// <summary> /// 总页数 /// </summary> public int TotalPages { get; private set; } public PagedList(List<T> source, int pageIndex, int pageSize) { PageIndex = pageIndex; PageSize = pageSize; TotalCount = source.Count(); TotalPages = (int)Math.Ceiling(TotalCount / (double)PageSize); this.AddRange(source.Skip((PageIndex-1) * PageSize).Take(PageSize)); } public PagedList(IQueryable<T> source, int pageIndex, int pageSize) { PageIndex = pageIndex; PageSize = pageSize; TotalCount = source.Count(); TotalPages = (int)Math.Ceiling(TotalCount / (double)PageSize); this.AddRange(source.Skip((PageIndex-1) * PageSize).Take(PageSize)); } public PagedList() { // TODO: Complete member initialization } /// <summary> /// 是否包含上一页 /// </summary> public bool HasPreviousPage { get { return (PageIndex > 1); } } public bool HasNextPage { get { return (PageIndex < TotalPages); } } internal void InsertRange(int p, Models.Admins prolistItem) { throw new NotImplementedException(); } } }
自定义分页
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。