Reputation: 363
my controller's methods uses the same query result to return various result (Jsonresult,actionresult) is there a way to cache the result in memory so that there is only one trip to data base for all controller methods so instead of executing the query the methods uses the result in cache
the variable that i want to cache is var x = from cus in db.BIOBillPh( )
public ActionResult BillPhp(string CodePays)
{
var x = from cus in db.BIOBillPh( )
select cus;
return PartialView(x);
}
public JsonResult PaysBU(string Pays)
{
var x = from cus in db.BIOBillPh()
select cus;
return Json(x, JsonRequestBehavior.AllowGet);
}
Upvotes: 1
Views: 1273
Reputation: 886
Controller instances are created on every call so not really. You could create an static interim object within your controller that would have some life span before refreshing db calls. Is this an action that's called with high frequency? The marginal, if any reduction in overhead might not be worth your time.
Upvotes: 1