What is the best practice for pagination in Entity framework?
Should one hit database twice, one to get total record count and second to get the records?
Thanks in advance.
What is the best practice for pagination in Entity framework? Should one hit database
Share
One solution would be to use a LINQ query which uses the Skip and Take operators.
Example – Page 1:
Example – Page 2:
Then you can define a page size variable and use that as the parameter to the
TakeandSkip (page size variable * (page number - 1))operator.And yes, one hit to get the total record count, to get the total number of pages.