I wrote a small library to use for easier pagination
In your application code
var result = source.ToPagedList(pageNumber, pageSize);
var result = source.ToPagedList(x => new Foo() {Id= x.Id, Code= x.Code }, pageNumber, pageSize);
Async Method
var result = await source.ToPagedListAsync(pageNumber, pageSize);
var result = await source.ToPagedListAsync(x => new Foo() {Id= x.Id, Code= x.Code }, pageNumber, pageSize);
First, install NuGet. Then, install PagedListExtensions from the package manager console:
PM> Install-Package PagedListExtensions