You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Tool
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public class PagedList<T>
|
|
|
|
|
{
|
|
|
|
|
public List<T> Items { get; private set; } // 存储当前页的元素
|
|
|
|
|
public int PageIndex { get; private set; } // 当前页码(从1开始)
|
|
|
|
|
public int PageSize { get; private set; } // 每页的元素数
|
|
|
|
|
public int TotalCount { get; private set; } // 总记录数
|
|
|
|
|
public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize); // 总页数
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool HasNextPage => PageIndex < TotalPages;
|
|
|
|
|
|
|
|
|
|
public PagedList(List<T> items, int count, int pageIndex, int pageSize)
|
|
|
|
|
{
|
|
|
|
|
Items = items;
|
|
|
|
|
TotalCount = count;
|
|
|
|
|
PageIndex = pageIndex;
|
|
|
|
|
PageSize = pageSize;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|