Using NHibernate with transaction scope
Reliable integration with other systems is a common business requirement. When these systems report error conditions, it's necessary to roll back not only the local database work, but perhaps the work of multiple transactional resources. In this recipe, we'll show you how to use Microsoft's transaction scope and NHibernate to achieve this goal.
Getting ready
Follow the Getting ready step in the Save entities to the database recipe in this chapter.
How to do it…
- Add a reference to
System.Transaction
. - Add a folder named
UsingTransactionScope
to the project. - Add a public interface named
IReceiveProductUpdates
to the folder:using NH4CookbookHelpers.Queries.Model; namespace SessionRecipes.UsingTransactionScope { public ...
Get NHibernate 4.x Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.