SELECT * FROM (SELECT *,ROW_NUMBER() OVER (ORDER BY 会员编号 DESC) AS RowNumber FROM Mold_List ) T WHERE T.RowNumber BETWEEN @PageSize*(@StartPage-1)+1 AND @PageSize*@StartPage
辅助类:
namespace MvcMovie.Utility { /// <summary> /// 分页帮助类 /// </summary> public class PageHelper { public PageHelper(int pageSize, int pageIndex) { this.PageSize = pageSize; this.PageIndex = pageIndex; } private long _count = 0; /// <summary> /// 总记录数 /// </summary> public long Count { get { return _count; } set { _count = value; TotalPage = CalacTotalPage(value); } } /// <summary> /// 总页数 /// </summary> public int TotalPage { get; private set; } = 1; /// <summary> /// 当前页 /// </summary> public int PageIndex { get; set; } = 1; /// <summary> /// 页大小(一页显示的记录条数) /// </summary> public int PageSize { get; set; } = 10; /// <summary> /// 计算总页数 /// </summary> /// <param name="count">总记录数</param> /// <returns></returns> public int CalacTotalPage(long count) { return (int)Math.Ceiling(count * 1.0 / PageSize); } /// <summary> /// 页开始记录位置 /// </summary> public int StartIndex { get { return (int)(PageIndex - 1) * PageSize; } } /// <summary> /// 是否有上一页 /// </summary> /// <returns></returns> public bool HasPrevious { get { return PageIndex > 1; } } /// <summary> /// 是否有下一页 /// </summary> /// <returns></returns> public bool HasNext { get { return PageIndex < TotalPage; } } /// <summary> /// 上一页页码 /// </summary> public int PreviousPageIndex { get { int index = PageIndex - 1; if (index > 0) { return index; } return 1; } } /// <summary> /// 下一页页码 /// </summary> public int NextPageIndex { get { int index = PageIndex + 1; if (index <= TotalPage) { return index; } return TotalPage; } } } }
标签:PageIndex,return,分页,PageSize,get,int,查询,Sql,public From: https://www.cnblogs.com/friend/p/18132586