Reputation: 764
I need to choose between TransactionScope or NHibernate transactions for my new project. What is better? When should use TransactionScope? NHibernate transactions?
Upvotes: 2
Views: 1598
Reputation: 5
Transaction management is exposed to the application developer via the NHibernate ITransaction interface. You aren’t forced to use this API—NHibernate lets you control ADO.NET transactions directly.
Upvotes: 0
Reputation: 52745
They are different things.
You should always do your work inside a NHibernate transaction.
You can use TransactionScope as needed, for example. to use distributed transactions when there's more than one session involved.
NHibernate transactions will automatically enlist in distributed transactions, but they won't be created automatically, so the recommended pattern is: if you have a TransactionScope, open the NH transaction inside it.
Upvotes: 6