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

c#, nhibernate, sql

Solution

`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;
        }
    }

Problem

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.

Original source