简体   繁体   中英

Loading data from a Microsoft SQL Server view using ASP.NET Core 3.1 and EF Core

I am loading data from my controller into a html table (view) - approx. 4000 records

public async Task<IActionResult> Index()
{
      var assignments = await _context.myData.ToListAsync();
      return View(myData);
}

I then select a record and view the details. All good at this point. I then go back to the index view to look at another record and all the data loads again.

This is not ideal as I have to wait for all the data to load each time before I can view the details of another record. I am wondering how to deal with this. Ideally the table of data will be cached for a period of time before reloading.

Any advice is much appreciated.

Jono

You have a different style of caching that you could use in your case, below two ways that I could recommend for you:

  • you can apply a cache for your action using ResponseCache so your can minimize server processing for requests
  • you can cache your assignment oject, here is an example how to do it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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