skip to Main Content

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?

2

Answers


  1. 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

    Login or Signup to reply.
  2. This is very common problem for developers…ha ha

    Every on has a different way to handle that. I would like to suggest 2 ways.

    1. You can handle that by SQL Server in stored procedure using count from to
    2. You can handle that by pagination on paging number call run time data on number click
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search