Is it possible to get the DbConnection and DbTransaction objects from a NHibernate transaction?
I need to combine some NHibernate calls with a third-part library inside the same transaction.
ISession.Connection returns the IDBConnection object. For the transaction see the blog post below.
//http://ayende.com/blog/1583/i-hate-this-code
private static IDbTransaction GetTransaction(ISession session)
{
using (var command = session.Connection.CreateCommand())
{
session.Transaction.Enlist(command);
return command.Transaction;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With