开发者

Is it possible to determine if a LinqToSql context was disposed?

开发者 https://www.devze.com 2023-04-01 16:44 出处:网络
I found no way to determine if a context was dis开发者_Go百科posed or not because it isn\'t set to null and it doesn\'t have a State property or something.If you Dispose your DataContext this way...

I found no way to determine if a context was dis开发者_Go百科posed or not because it isn't set to null and it doesn't have a State property or something.


If you Dispose your DataContext this way...

using (CustomDataContext myDC = new CustomDataContext())
{
  //use myDC to do something
}

The variable referencing the datacontext instance goes out of scope at the same time as the instance is disposed - which means you don't have to keep track.

0

精彩评论

暂无评论...
验证码 换一张
取 消