O'Reilly logo

NHibernate 3.0 Cookbook by Jason Dentler

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 TransactionScope

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, I'll show you how to use Microsoft's TransactionScope and NHibernate to achieve this goal.

Getting ready

Create a new console application project.

Add references to the Eg.Core project in Chapter 1, NHibernate.dll, and NHibernate.ByteCode.Castle.dll.

Get the console application ready by following the Configuring NHibernate with App.config and Configuring log4net recipes in Chapter 2.

How to do it...

  1. Add a reference to System.Transaction.
  2. Add a public interface named ...

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