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.
Follow the Getting ready step in the Save entities to the database recipe in this chapter.
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 interface IReceiveProductUpdates { void Add(Product product); void Update(Product product); void Remove(Product product); } }
Add a public class named
WarehouseFacade
with this code:public class WarehouseFacade : IReceiveProductUpdates...