简体   繁体   中英

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

How to keep 990 rows of data in the controller ?

You can make use of Caching for this

Either use the System.Web.Caching

Or use MemoryCache

Depending on you setup, you might also be able to use 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.

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.

Since you are using MVC, you can take advantage of new option such as ViewData and 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.

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