Paging class, php paging class
/// <Summary> /// paging // </summary> /// <typeparam name = "T"> type </typeparam> public class PagedList <T>: list <T> {// <summary> // cache paging constructor // </summary> // <param name = "source"> data source </param> /// <param name = "pageIndex"> current page number </param> /// <param name = "pageSize"> Number of records displayed on each page </param> public pagedList (IQueryable <T> source, int pageIndex, int pageSize) {if (source = null |! Source. any () throw new ArgumentNullException ("source"); int total = source. count (); TotalCount = total; TotalPages = total/pageSize; if (total % pageSize> 0) TotalPages ++; PageSize = pageSize; PageIndex = pageIndex; AddRange (source. skip (pageIndex * pageSize ). take (pageSize ). toList ());} /// <summary> /// cache paging constructor /// </summary> /// <param name = "source"> data source </param> /// <param name = "pageIndex"> current page number </pa Ram> // <param name = "pageSize"> Number of records displayed per page </param> public PagedList (IList <T> source, int pageIndex, int pageSize) {if (source = null |! Source. any () throw new ArgumentNullException ("source"); TotalCount = source. count (); TotalPages = TotalCount/pageSize; if (TotalCount % pageSize> 0) TotalPages ++; PageSize = pageSize; PageIndex = pageIndex; AddRange (source. skip (pageIndex * pageSize ). take (pageSize ). toList ());} /// <summary> /// non-Cache paging constructor // </summary> /// <param name = "source"> data source </param> /// <param name = "pageIndex"> current page number </param> /// <Param name = "pageSize"> Number of records displayed per page </param> // <param name = "totalCount"> total number of records </param> public PagedList (IEnumerable <t> source, int pageIndex, int pageSize, int totalCount) {if (source = null |! Source. any () throw new ArgumentNullException ("source"); TotalCount = totalCount; TotalPages = TotalCount/pageSize; if (TotalCount % pageSize> 0) TotalPages ++; PageSize = pageSize; pageIndex = pageIndex; AddRange (source) ;}/// <summary >/// current page number /// </summary> public int PageIndex {get; private set ;} /// <summary> /// number of records displayed on each page /// </summary> public int PageSize {get; private set ;} /// <summary> /// total number of records /// </summary> public int TotalCount {get; private set ;} /// <summary> /// total number of pages /// </summary> public int TotalPages {get; private set ;} /// <summary> /// previous page exists /// </summary> public bool HasPreviousPage {get {return (PageIndex> 0 );}} /// <summary> /// there is a next page // </summary> public bool HasNextPage {get {return (PageIndex + 1 <TotalPages );}}}