日期:2014-05-17 浏览次数:20437 次
var comments=new PagedList<Comment>( ((IEnumerable<Comment>)db.ExecuteQuery<Comment>(StrSql) ).ToList(),pageIndex,pageSize,totalCount)
public class PagedList<T> : List<T>,IPagedList { public PagedList(IEnumerable<T> items, int pageIndex, int pageSize, int totalItemCount) { AddRange(items); TotalItemCount = totalItemCount; CurrentPageIndex = pageIndex; PageSize = pageSize; } public int CurrentPageIndex { get; set; } public int PageSize { get; set; } public int TotalItemCount { get; set; } public int TotalPageCount { get { return (int)Math.Ceiling(TotalItemCount / (double)PageSize); } } public int StartRecordIndex { get { return (CurrentPageIndex - 1) * PageSize + 1; } } public int EndRecordIndex { get { return TotalItemCount > CurrentPageIndex * PageSize ? CurrentPageIndex * PageSize : TotalItemCount; } } }