My controller has different methods that use the same result returned by a stored procedure called by a LINQ query, Is there a way to create a global variable that contains the result after making only one call to the procedure ??
I tried creating a constructor but every time the variable (ListePays) is used a new query is executed
public class BUController : Controller {
private NAV_MAUIEntities db = new NAV_MAUIEntities();
public DbSet<liste_pays> ListePays;
public BUController() {
ListePays = db.liste_pays();
}
public JsonResult BillPh(string Pays) {
var x = from pays in ListePays
where pays.Pays.ToUpper() == Pays.ToUpper()
select pays.code_pays;
string CodePays = x.FirstOrDefault().ToString();
}
public JsonResult BillPh2(string Pays) {
var x = from pays in ListePays
where pays.Pays.ToUpper() == Pays.ToUpper()
select pays.code_pays;
string CodePays = x.FirstOrDefault().ToString();
}
}