Is it possible to determine if a LinqToSql context was disposed?
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.
精彩评论