Singleton pattern in web applications

前端 未结 5 1149
萌比男神i
萌比男神i 2021-02-05 21:46

I\'m using a singleton pattern for the datacontext in my web application so that I dont have to instantiate it every time, however I\'m not sure how web applications work, does

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 21:59

    Many people keep the DataContext around for the duration of the request by keeping it in the HttpContext.Current.Items Thereby it is also private to the request.

    Have a look at this blogpost by Steve Sanderson, and the UnitOfWork pattern.

提交回复
热议问题