DAAB & Web Services

Topics: Data Access Application Block
Aug 7, 2008 at 1:12 PM
I've just started playing around with the DAAB in an ASP.NET web service. I'm not sure what the "best practice" would be in the following areas, so would appreciate some advice:

1. Should I call CreateDatabase() on every web service call (say via the WS constructor), or should I create it once and store it in the Application object? I did note the comment in the docs about "therefore, you do not need to cache your Database objects".
2. How are multiple simultaneous create requests handled? If I have 3 clients come in on separate calls, does there end up being 3 connections to the DB, or does CreateDatabase() give me a reference to the one underlying object?

Thanks for your time - I'm sure there'll be more questions to come.
Aug 7, 2008 at 5:39 PM


You can share the Database instances. A connection is established each time you invoke a method on the Database object (eg ExecuteNonQuery()), unless you're using the transaction scope support (but the TransactionScope is supported by thread local storage, so different requests on different threads should not interfere).