传递大量列表以在mvc5中查看

Pass massive list to view in mvc5
2020-11-25
  •  译文(汉语)
  •  原文(英语)

我正在使用MVC 5 Web应用程序,在此应用程序上,我正在使用Web服务搜索酒店.我的客户填写查询和提交字段.每个查询的响应是一个大规模模型,例如1000个模型,每个模型都包含其他大规模模型.显示此结果的最佳方法是什么?在db中具有Information的类似条件下,我使用如下页面调度:

public IList<Result> Search(SearchModel searchModel, int pageNumber, int recordsPerPage = 15)

我可以将每个客户的结果保存在内存中并可以对结果进行分页吗?

有更好的主意吗?

速聊1:
您可以改用javascript和通过json动态加载,而不是像这样.
解决过程1

显示此结果的最佳方法是什么?

如果可能的话,您急切地想知道如何在结果集上实现分页.这完全取决于您使用的此Web服务是否支持分页.希望能.这里需要避免的主要事情是将大数据加载到内存中,然后将其发送到客户端的设备/浏览器,因为不需要它,人眼将无法同时看到100多个记录.而且,显而易见的是,无论服务器的功能多么强大,它都会浪费资源,例如内存和CPU使用率.

我建议您找出此Web服务是否支持分页.如果不这样做(很奇怪不会),例如运行查询并将其存储在数据库中的Windows Service之类的后台工作程序可能会做,那么您的Web应用程序就可以轻松地将数据库中的结果分页到产生分页的结果集.

I'm working on a MVC 5 web application, On this app i'm using web service to search in hotels. My customers complete fields of query and submit. Response of per query is a massive model,as example 1000 model, that each contains other massive models. What is best way to display this result? On similar conditions that have Information in db, I use paging like this:

public IList<Result> Search(SearchModel searchModel, int pageNumber, int recordsPerPage = 15)

Can i keeping result of per customer in memory and do paging on result?

Any better idea?

Talk1:
You could switch to using javascript and dynamic loading via json instead of doing it like this.
Solutions1

What is best way to display this result?

Eagerly, if possible, and you already have an idea of how to implement paging on a result set. It all depends on whether this web service you're consuming supports paging. Hopefully it does. The main thing you need to avoid here is loading big data in memory and then send it to a client's device/browser because it's not needed, the human eye will not be able to see 100+ records at the same time; that, plus the obvious, it's a waste of resources such as memory and CPU usage...no matter how powerful your server(s) are.

I'd suggest you to find out if this web service supports paging. If it doesn't (would be weird not to) maybe some sort of background worker such as a Windows Service that runs the query and stores them in a database would do, then your web app can easily page through the results in the database to produce a paged result set.

转载于:https://stackoverflow.com/questions/28061313/pass-massive-list-to-view-in-mvc5

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入