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.

  1. 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;     } } 
  2. 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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -