I have always been under the impression that it is best to open the connection immediately before executing a query and closing it directly after. Open late and release early. By opening the connection in OnBeginRequest, and closing the connection in OnEndRequest the same open connection is used throughout the lifetime of the request, which may include a large number of database queries.
An alternative approach would be to assign the connection without opening it. It would then be the responsibility of the code which executes the Database queries to open and close the connection as needed. Once again, I am looking at this through the eyes of someone with little knowledge about the inner workings of AR. On Jan 30, 1:58 pm, Markus Zywitza <[email protected]> wrote: > > As for the DB connection, I was wondering more about the impact of > > using a single open database connection per http request rather than > > retrieving a connection from the pool per database request. In any > > case, It does not look like the latter is possible with this approach. > > Can you please explain on that? > > The DB connection is at your full responsibility. I'd get it from a > pool in OnBeginRequest, store it in the context and return it in > OnEndRequest. > > However, if you need that feature for a regular test/production > staging, I recommend using different instances of your application. > NAnt does a good job adjusting XML config values for multiple > instances. > > -Markus --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" 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/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
