简体   繁体   English

从表中读取数据时显示当前加载的数据

[英]Displaying the currently loaded data while reading data from a table

I have a SQL Server table that has approximately 2 million rows.我有一个大约有 200 万行的 SQL 服务器表。 Let's say the table is called Students .假设该表名为Students If I query a database from SQL Server Management Studio:如果我从 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.同时显示当前加载的数据,同时正在加载其rest。 By this I mean, for example after 1 second I see 1000 lines, after 2 seconds I see 3000 lines and so on....我的意思是,例如 1 秒后我看到 1000 行,2 秒后我看到 3000 行等等......

However, if I use EF in my application and I query the database for the data:但是,如果我在我的应用程序中使用 EF 并在数据库中查询数据:

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).我必须等待表的所有行加载完毕才能访问data object。我知道理论上我可以使用分页并仅检索部分记录(例如,从 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?但是 ASP.NET 核心应用程序中是否有任何机制/库可以让我在页面上显示表格并动态加载行?

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?但是 ASP.NET 核心应用程序中是否有任何机制/库可以让我在页面上显示表格并动态加载行?

In a web app the most common pattern is to return data one page at-a-time.在 web 应用程序中,最常见的模式是一次返回一页数据。 Any time the user hits [Next] or scrolls down on the table, the next page of data is fetched.每当用户点击 [Next] 或向下滚动表格时,都会获取下一页数据。 This is called Paging (like Stack Overflow) or Virtual Scrolling (like Facebook).这称为分页(如 Stack Overflow)或虚拟滚动(如 Facebook)。

See eg Tutorial: Add sorting, filtering, and paging - ASP.NET MVC with EF Core参见例如教程:添加排序、过滤和分页 - ASP.NET MVC with EF Core

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.我想建议2种方法。

  1. you can handle that by SQL server in store procedure using count from to.您可以通过 SQL 服务器在存储过程中使用 count from to 来处理它。
  2. you can handle that by pagination on paging number call run time data on number click.您可以通过在点击号码时对寻呼号码呼叫运行时间数据进行分页来处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM