Hello, we have a DAL that needs to wrap many database inserts in a single transaction that we can rollback or commit.
What is the best practice for handling that?
We are currently doing the following:
- Create DB Connection and Transaction
- Fill a collection with all the classes that represent an action to perform. Pass in the connection via constructor.
- In a try/catch, loop through all the action classes and call thier Publish() method
- Commit if successful (closes connection) or rollback if errors (closes connections).
The process can take sometime and we seem to be running out of pooled database connections. Is there a better way to manage the transactions?
This is using SQL 2008, .net 3.5 and the 4.1 version of enterprise library data access.