c# - why EF takes a long time in first called method -
i'm working @ application on web , i'm using ef create model , accessing db.
create session var use in session level:
private model.websitemodelcontainer s_defaultmodel; public model.websitemodelcontainer defaultmodel { { s_defaultmodel = httpcontext.current.session["defaultmodel"] websitemodelcontainer; if (s_defaultmodel == null) { s_defaultmodel = new model.websitemodelcontainer(); httpcontext.current.session["defaultmodel"] = s_defaultmodel; } return s_defaultmodel; } }
use defaultmodel in code:
return defaultmodel.ages.orderby(c => c.agename).tolist();
after new build of project, first database query executed causes ef build views uses data access. can cause significant delay. can work around having ef pre-compile views. see how to: pre-generate views improve query performance msdn.
Comments
Post a Comment