O'Reilly logo

NHibernate 4.x Cookbook - Second Edition by Jason Dentler, Alexander Zaytsev, Gunnar Liljas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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…

  1. Add a reference to System.Transaction.
  2. Add a folder named UsingTransactionScope to the project.
  3. Add a public interface named IReceiveProductUpdatesto the folder:
    using NH4CookbookHelpers.Queries.Model; namespace SessionRecipes.UsingTransactionScope { public ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required