Force the Opening of the DataContext's Connection (LINQ)
When you create a datacontext, its connection is closed until you retrieve objects a开发者_开发技巧nd it stays open when you retrieve objects in case you use deferred operators or late binding.
Is it possible (in an extension method of the datacontext of not) to force the datacontext to open its Connection without querying LINQ with LINQ or doing a fake query to the database with ExecuteQuery, ExecuteCommand, etc?
Thanks
You can use the DataContext.Connection
property to retrieve the connection, and call Open()
yourself.
精彩评论