I’d like to use System.Transactions.Transaction with the Enterprise Library 5.0. The Enterprise Library allows passing a System.Data.Common.DbTransaction type with Execute* functions. It tried to cast to System.Transactions.Transaction to System.Data.Common.DbTransaction without luck.
Code:
Database db = null;
object returnValue;
Transaction ambientTransaction = Transaction.Current;
db = DatabaseFactory.CreateDatabase(MainConnection);
returnValue = db.ExecuteScalar((DbTransaction)ambientTransaction, procedureName, parameterValues);
How would I use use System.Transactions.Transaction with the Enterprise Library 5.0?
It appears you don’t need to pass it explicitly, support is built into Enterprise Library from version 3.0 and higher. It looks for the current transaction and uses it if available. Found the answer at David Hayden’s site.