This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi! We have a problem with connections that are not closed after using the Repository(.Find etc.). Our application is a web-application and we are for the moment using MySql. For each post-back, a new connection is opened in UnitOfWork.cs in the first Repository.Find. This connection is not closed (UnitOfWork.Dispose is never run), and on the next post-back a new connection is opened and so on. So we run out of connections pretty quick. If I do a Repository.CompleteUnitOfWork, the connection is closed, but I shouldn't have to do that for read-only operations? And I would like to do it only once, when leaving the post-back, not after each Repository.Find. Is this a bug, or should we solve it by calling CompleteUnitOfWork in some clever way (Page_Unload)? Best regards Björn Andersson Admeta AB |
|
|
Hi Björn For a web app you basically want to be using what's known as the Session-per-request pattern. Basically one unit of work per web request. In some of our samples we do this by calling CompleteUnitOfWork in Page Unload. Alternatively, you may like to do it in the HttpApplication.EndRequest event. Additionally, I've just checked in experimental support for automatically closing any open units of work at the end of web requests - available tomorrow. Cheers, Andrew. |
|
|
Great! But I dont think this is very clear from the documentation. Actually, I'm not sure I would have found it out unless I've had access to the source code. On the other hand, I often miss things like these, and I'm also new at it.. But as I read from the docs it seem to indicate that this is handled automatically. |
|