[英]ASP.NET MVC get data from SQL Server with WCF : how to put temporary data store in controller
I want to do grid, I get 1000 rows of data from SQL Server with WCF, then I put grid 10 data in view in first after use scroll and get 10-20 data from controller in two after use scroll and get 20-30 data from controller in three..... use scroll and get 990-1000 data from controller.我想做网格,我使用 WCF 从 SQL Server 获取 1000 行数据,然后在使用滚动后首先将网格 10 数据放入视图中,并在使用滚动后从控制器中获取 10-20 数据并获取 20-30 数据从控制器中的三个..... 使用滚动并从控制器获取 990-1000 数据。 But I must go SQL Server with WCF only one time for 1000 rows of data (I cannot go to SQL Server all time (example 0-10,10-20,20-30)) and I put 10 data grid in view, problem is 990 rows of data in controller.
但是对于 1000 行数据,我必须只使用 WCF一次使用 SQL Server(我不能一直使用 SQL Server(例如 0-10,10-20,20-30))并且我将 10 个数据网格放在视图中,问题是控制器中的 990 行数据。
How to keep 990 rows of data in the controller ?如何在控制器中保留 990 行数据?
You can make use of Caching
for this您可以为此使用
Caching
Either use the System.Web.Caching要么使用System.Web.Caching
Or use MemoryCache或者使用内存缓存
Depending on you setup, you might also be able to use OutputCache
根据您的设置,您可能还可以使用
OutputCache
[OutputCache(Duration=10, VaryByParam="none")]
public ActionResult Result()
{
return Data();
}
See http://www.asp.net/mvc/overview/older-versions-1/controllers-and-routing/improving-performance-with-output-caching-cs for more around this.有关更多信息,请参阅http://www.asp.net/mvc/overview/older-versions-1/controllers-and-routing/improving-performance-with-output-caching-cs 。
your description is quite confusing.你的描述相当混乱。 Sorry if I misunderstood your requirement.
对不起,如果我误解了你的要求。
If it involve over 1000+ of data, session is not a good option especially if your program involve other usage of session.如果它涉及超过 1000 多个数据,则 session 不是一个好的选择,特别是如果您的程序涉及 session 的其他用法。
Since you are using MVC, you can take advantage of new option such as ViewData and TempData.由于您使用的是 MVC,您可以利用新选项,例如 ViewData 和 TempData。 You can read more about it here .
您可以在此处阅读更多相关信息。
I used TempData before and it can process large amount of data (I did not count how much it was, but consider quite huge) so it should be a much better option than session.我之前用过 TempData ,它可以处理大量数据(我没有计算它有多少,但认为相当大)所以它应该是一个比 session 更好的选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.