We need to fetch data from a database using LINQ. We now need to implement pagination.
I suppose at a time we need to fetch 10
records at a time and when we click the Next button then it will fetch the next 10
records from db.
Please guide me with code. thanks
.Skip
and.Take
extension methods could be used:The LINQ Take() function will limit how many items are taken. The Skip() function will ignore the first n items. Something like this might work:
I always use the following code:
That is a static class, which you can include in your sources. After adding this class you can do the following: