记载abp中Dbcontext的疑问

  q:abp中httpcontext如何在一次请求中保证获取的是相同的实例。

  大牛的原话:

   LifestylePerWebRequest does not works good with async. That's why I used CallContext.
Also, I don't want to use same DbContext for entire web request. Instead, create/use/dispose when needed (per unit of work). Lastly, ABP also supports to non-web applications (like Windows services). So, I did not use HttpContext or LifestylePerWebRequest to follow same model in all platforms.

  在异步使用中,ioc的LifestylePerWebRequest 不稳定。所以选用了线程槽,一次请求对应唯一工作单元,工作单元中获取工作单元。总体思路是用到才会及时加载运行。

原文地址:https://www.cnblogs.com/JaggerMan/p/5111055.html