using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SlnMesnac.RfidUpload.Common { public class ListPage { public int TotalPage { get; set; } public int Total { get; set; } public int PageSize { get; set; } = 50; public List Ls { get; set; } public ListPage(IEnumerable ls, int pageSize = 500) { if (!(ls is T[] objArray)) objArray = ls.ToArray(); T[] source = objArray; this.Ls = ((IEnumerable)source).ToList(); this.Total = ((IEnumerable)source).Count(); this.PageSize = pageSize; this.TotalPage = (((IEnumerable)source).Count() + this.PageSize - 1) / this.PageSize; } public IEnumerable> GetPage() { List> page = new List>(); for (int index = 0; index < this.TotalPage; ++index) { IEnumerable objs = this.Ls.Skip(this.PageSize * index).Take(this.PageSize); page.Add(objs); } return (IEnumerable>)page; } } }