I always use the following code:
public static class PagingExtensions
{
//used by LINQ to SQL
public static IQueryable Page(this IQueryable source, int page, int pageSize)
{
return source.Skip((page - 1) * pageSize).Take(pageSize);
}
//used by LINQ
public static IEnumerable Page(this IEnumerable source, int page, int pageSize)
{
return source.Skip((page - 1) * pageSize).Take(pageSize);
}
}
That is a static class, which you can include in your sources.
After adding this class you can do the following:
MyQuery.Page(pageNumber, pageSize)