On Jun 16, 12:12 pm, Jonathan Pryor <[email protected]> wrote: > On Mon, 2009-06-15 at 16:21 -0700, greyman wrote: > > The key there is that > > DataContext should not attempt to open any IDbConnection more than > > once. > > This is also wrong. MSDN explicitly documents[0] that the IDbConnection > will be kept open for as short a period as possible, for each SQL > request sent to the DB. Consequently, assuming that the IDbConnection > is closed during DataContext construction, it will be .Open()ed > AND .Close()d for each SQL request, which could be more than once. > > Specifically, at minimum every DataContext.SubmitChanges() call should > result in both opening and closing the IDbConnection (along with every > query traversal, etc.). > > - Jon > > [0]http://msdn.microsoft.com/en-us/library/bb292288.aspx
Fair enough. I can tell you from experience though that no matter what MSDN says there are at least some ADO.Net data providers that work a lot better from a fault tolerance point of view if you create a new IDbConnection object rather than opening a closed one. If you close you IDbConnection and then the network connection to the db is lost or the db just happens to decide to timeout the process for your connection then calling open on the physical connection will fail. Creating a new IDbConnection allows the ADO.Net provider connection pool to allocate a new working connection. I have tested this with DbLinq by knocking off the thread processing a MySQL connection. The DataContext does not cope and the application will need to try and work out what state the DataContext was in and recover and resubmit. With Postgresql I've seen my physical connections timeout and the same thing happen. Regards, Aaron --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DbLinq" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/dblinq?hl=en -~----------~----~----~----~------~----~------~--~---
