Skip to content

Instantly share code, notes, and snippets.

@troygoode
Created June 29, 2011 04:03
Show Gist options
  • Save troygoode/1053069 to your computer and use it in GitHub Desktop.
Save troygoode/1053069 to your computer and use it in GitHub Desktop.
PagedList Example
const int pageSize = 10;
var allProducts = database.Products.All(); //15 products
//products 1-10
var firstPage = allProducts.ToPagedList(0, pageSize);
Assert.Equal(10, firstPage.Count);
Assert.False(firstPage.HasPreviousPage);
Assert.True(firstPage.HasNextPage);
//products 11-15
var secondPage = allProducts.ToPagedList(1, pageSize);
Assert.Equal(5, secondPage.Count);
Assert.False(secondPage.IsFirstPage);
Assert.True(secondPage.IsLastPage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment