Created
October 2, 2018 13:16
-
-
Save mikebrind/7f53ad1d9bd1570c67bca3553b6d21c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} |
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
Your tutorial fails to warn people that it doesn't work with large amounts of data. I have an app that keeps timing out because when GetData() as used here https://www.mikesdotnetting.com/article/328/simple-paging-in-asp-net-core-razor-pages gets too big it gets really slow. To make matters works adding more RAM and caching the GetData() result using LazyCache doesn't solve the problem either.
Please update your tutorial to cover scenarios when GetData() includes over 1,000 rows from a database so that I don't end up getting the entire table. Thank you.