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.
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.
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
}