Reputation: 5804
I'm using SubSonic 3.0 (SimpleRepository) to handle database access in my ASP.NET MVC 1.0 application.
It would be nice to handle a transaction for every web request, committing if everything went smooth and rolling back in case of exception. Is this possible? If so, how?
I know this topic has been discussed many times, but I just couldn't find a satisfactory answer. I have built my own solution (create a TransactionScope in the controller, then commit/rollback in OnActionExecuted), but it turns out to be very unreliable.
Upvotes: 2
Views: 554
Reputation: 632
The link http://ayende.com/Blog/archive/2011/04/12/refactoring-toward-frictionless-amp-odorless-code-what-about-transactions.aspx applies to NHibernate but i am quite sure you can use it as well. Basically it talks about creating custom action filter . It is also true that it does it action-wide not request wide.
Upvotes: 1