Fork me on GitHub

PageLinqExtensions class

This class contains two ToPagedList extension methods which return a strongly typed PagedList<T> object, one for IQueryable<T> and one for IEnumerable<T>

IQueryable<T>.ToPagedList extension method:

Syntax:
public static PagedList<T> ToPagedList<T> (this IQueryable<T> allItems,int pageIndex, int pageSize )
Usage:
var query=db.Articles.AsQueryable();
var model=query.ToPagedList(1,8);
Description:
Gets a strongly typed PagedList object using all items, current page index and page size.

IEnumerable<T>.ToPagedList extension method:

Syntax:
public static PagedList<T> ToPagedList<T>(this IEnumerable<T> allItems, int pageIndex, int pageSize)
Usage:
List<Article> arts=ArticleRepository.GetAllArticles();
var model=arts.ToPagedList(1,8);
Description:
Gets a strongly typed PagedList object using all items, current page index and page size.