When does the DataContext will open a connection to the DB?
- by Eran Betzalel
I am using L2S to access my MSSQL 2008 Express server. I would like to know when the DataContext will open a connection to the DB? and will it close the connection right after it opened it?
For example:
var dc = new TestDB(); // connection opened and closed?
dc.SomeTable.InsertOnSubmit(obj); // connection opened and closed?
foreach(var obj in dc.SomeTable.AsEnumerable()) // connection opened and closed?
{
... // connection opened and closed?
}
dc.SubmitChanges(); // connection opened and closed?