Skip to main content
2 of 2
deleted 3 characters in body
Berin Loritsch
  • 46.5k
  • 7
  • 93
  • 164

Your query for information will need to return both count of matching items as well as the current payload of information. Typically what I do for this scenario is to create a generic object that handles the pagination logic:

public class Page<T>
{
    public int Total {get;}
    public int PageSize {get;set;}
    public int PageNum {get;set;}
    public bool HasNext {get;}
    public bool HasPrevious {get;}
    public List<T> Records {get;}
}

Given the current page size and page, and the total number of records that apply to the query, everything else could be calculated. The container class Page<T> handled all the pagination logic, and it could be reused for any type we needed.

Berin Loritsch
  • 46.5k
  • 7
  • 93
  • 164