I have thousands of rows, but I don’t want to use just Users.ToList()
probably that is not efficient. I want to send just 20 or 30 row to API each request. Next 20 rows and next 20 rows I want to do like that, is it possible ?
Like Twitter or Instagram
What is the better solution in here?
Any video or article. I need some suggestion,
Thank you to everyone
Note: currently, I am using ASP.NET Core 5.0, I am using React Native as mobile development
2
Answers
Have your API endpoint accept page offset and page size parameters (how is up to you – query string, part of request body, etc). You can then use the
IQueryable<T>
.Skip
and.Take
extension methods to return the requested set of rows:Entity Framework has built-in support for paging. You could implement it pretty easily like so:
Then, you could call this extension method like so:
It is worth noting that this method doesn’t account for rows that may be inserted in the middle of a page between page requests; however, for a traditional table sorted by the primary key that is database-generated and auto-incrementing, this likely isn’t a material issue.