aspclassiccompiler/aspclassiccompiler/NerdDinnerAsp/Helpers/PaginatedList.cs
dotneteer ca696d1388 --HG--
extra : convert_revision : svn%3Aa83551a4-30f6-4d81-a974-c6ced450ddbf%4030470
2009-10-18 04:19:46 +00:00

35 lines
1,007 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
namespace NerdDinner.Helpers {
public class PaginatedList<T> : List<T> {
public int PageIndex { get; private set; }
public int PageSize { get; private set; }
public int TotalCount { get; private set; }
public int TotalPages { get; private set; }
public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize) {
PageIndex = pageIndex;
PageSize = pageSize;
TotalCount = source.Count();
TotalPages = (int) Math.Ceiling(TotalCount / (double)PageSize);
this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize));
}
public bool HasPreviousPage {
get {
return (PageIndex > 0);
}
}
public bool HasNextPage {
get {
return (PageIndex+1 < TotalPages);
}
}
}
}