LinqToSql static DataContext in a web application

后端 未结 5 1106
囚心锁ツ
囚心锁ツ 2021-01-02 12:14

In a web application that I have run across, I found the following code to deal with the DataContext when dealing with LinqToSQL

public partial class DbDataC         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 12:41

    This is not a static copy. Note that the property retrieves it from Context.Items, which is per-request. This is a per-request copy of the DataContext, accessed through a static property.

    On the other hand, this property is assuming only a single thread per request, which may not be true forever.

提交回复
热议问题