A simple class that accepts a collection of items and paginates the results.
C#
Latest commit 3225123 Jan 20, 2015 @jonnale jonnale Update README.md
Added clarification
Permalink
Failed to load latest commit information.
CNPagedList.cs Update CNPagedList.cs Aug 14, 2014
README.md Update README.md Jan 20, 2015

README.md

.NET-CNPagedList

A simple class that accepts an IQueryable, a page number parameter, and a page size parameter, and paginates the results. This is useful when returning a paginated list from a WebApi project.

Usage

To create a paginated list:

CNPagedList<Model> pagedList = new CNPagedList<Model>(queryable, page, pageLimit);

The parameters page and pageLimit are optional. If they are not provided, the CNPagedList will contain all of the items in the queryable.

JSON Example

This is an example of a JSON response returned from the WebApi.

... assume we specify page size of 3, and there are a total of 10 items ...

{
  "items": [
    {
      "name":"Item 1"
    },
    {
      "name":"Item 2"
    },
    {
      "name":"Item 3"
    }
  ],
  "page": 1,
  "pageSize":3,
  "totalItemCount":10
}