2

I have legacy dll which uses multiple NHibernate transactions in one method. My task is to make this method act as one transaction, so I think TransactionScope should help me. However, when I made something like this:

using (TransactionScope tx = new TransactionScope())
{
    #region.. code inside dll

    using (ISession session1 = ...)
    using (ITransaction tx1 = session.BeginTransaction())
    {
        // ...do work with session
        tx1.Commit();
    }

    using (ISession session2 = ...)
    using (ITransaction tx2 = session.BeginTransaction())
    {
        // ...do work with session
        tx2.Commit();
    }

    #endregion

    tx.Complete();
}

...method is not rolledback if tx2 falls!

I would very much appreciate any suggestion or hint..

Thank you in advance

Artless
  • 4,522
  • 1
  • 25
  • 40
nanek
  • 137
  • 1
  • 5
  • Is this your actual code? It looks very similar to [this](http://stackoverflow.com/a/5914015/1688378), taken from a very similar question about transaction scopes. – Artless Apr 01 '13 at 10:56
  • I was searching for solution, found that piece of code, so I used it to describe my problem – nanek Apr 01 '13 at 11:00

0 Answers0