TransactionScope promotes SysCache2 command dependency to a distributed transaction

Description

As you may know, NHibernate itself supports TransactionScope s very nicely (http://ayende.com/Blog/archive/2006/06/04/NHibernateAndSystemTransactionsASuccess.aspx), but we have found a small issue using them with SysCache2.

SysCache2.SqlCommandCacheDependencyEnlister executes its dependency command on a separate SqlConnection than the current NHibernate ISession. If there is an ambient transaction present (i.e. executing inside a TransactionScope), it will be promoted to a distributed transaction across the two connections.

This problem can be easily fixed if SqlCommandCacheDependencyEnlister uses a TransactionScope with TransactionScopeOption.Suppress, that will ignore any ambient transaction.

A patch for this is attached.

Environment

None

Assignee

Frédéric Delaporte

Reporter

Richard Dingwall

Components

Fix versions

Affects versions

Priority

Minor
Configure