我有一个应用程序,在数据库中完成分页.也就是说,检索项目列表的调用包括页码,页面大小,并且仅返回页面的数据.例如:
ItemCollection items = ListAllItems(1, 20); // page 1, show 20 items per page
Run Code Online (Sandbox Code Playgroud)
ItemCollection包含一个PagingUtil属性,该属性是一个包含支持分页但不检索所有记录的属性的类.
public class PagingUtil
{
public int StartRow { get; private set; }
public int EndRow { get; private set; }
public int TotalPages { get; private set; }
public bool HasPrevPage { get; private set; }
public bool HasNextPage { get; private set; }
public int TotalCount { get; private set; }
private PagingUtil() {}
public PagingUtil(int pageNumber, int visiblePerPage, int totalCount)
{
... logic …Run Code Online (Sandbox Code Playgroud)