Jonathan Allen Jonathan Allen - 1 year ago 112
SQL Question

Can I get the underlying conneciton and transaction objects from NHibernate?

Is it possible to get the

objects from a NHibernate transaction?

I need to combine some NHibernate calls with a third-part library inside the same transaction.

Answer Source

ISession.Connection returns the IDBConnection object. For the transaction see the blog post below.


    private static IDbTransaction GetTransaction(ISession session)

        using (var command = session.Connection.CreateCommand())
            return command.Transaction;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download