I have a SQL Server table that has approximately 2 million rows. Let's say the table is called Students
. If I query a database from SQL Server Management Studio:
SELECT *
FROM Students
At the same time, the currently loaded data is displayed, and the rest of it is being loaded in the meantime. By this I mean, for example after 1 second I see 1000 lines, after 2 seconds I see 3000 lines and so on ....
However, if I use EF in my application and I query the database for the data:
var data = _context.Students.ToList();
I have to wait for all the rows of the table to load before I can access the data
object.I know that theoretically I could use pagination and retrieve only part of the records (for example, from 1 - 100).
But is there any mechanism / library in the ASP.NET Core application that would allow me to display a table on the page and load the rows on the fly?
CodePudding user response:
But is there any mechanism / library in the ASP.NET Core application that would allow me to display a table on the page and load the rows on the fly?
In a web app the most common pattern is to return data one page at-a-time. Any time the user hits [Next] or scrolls down on the table, the next page of data is fetched. This is called Paging (like Stack Overflow) or Virtual Scrolling (like Facebook).
See eg Tutorial: Add sorting, filtering, and paging - ASP.NET MVC with EF Core