Skip to content

Instantly share code, notes, and snippets.

@mikebrind
Created October 2, 2018 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebrind/7f53ad1d9bd1570c67bca3553b6d21c1 to your computer and use it in GitHub Desktop.
Save mikebrind/7f53ad1d9bd1570c67bca3553b6d21c1 to your computer and use it in GitHub Desktop.
public class PaginationModel : PageModel
{
[BindProperty(SupportsGet = true)]
public int CurrentPage { get; set; } = 1;
public int Count { get; set; }
public int PageSize { get; set; } = 10;
public int TotalPages => (int)Math.Ceiling(decimal.Divide(Count, PageSize));
}
@mikebrind
Copy link
Author

Now all I need is some data. Usually this comes from a database, but I am using some dummy data formatted as JSON that's read from a file. My JSON will deserialise to a collection of Person objects:

It should be clear that the GetData method is there purely to provide some data for the paging demo and is a stand-in for a database. It is not intended to be used with a database. Nevertheless, I'll review the article and see if I can improve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment