How can I seperate my TransactionScope so they don't interfere with each other?

Posted by shenku on Stack Overflow See other posts from Stack Overflow or by shenku
Published on 2014-06-02T08:52:30Z Indexed on 2014/06/02 9:26 UTC
Read the original article Hit count: 166

Filed under:
|
|

I have some business logic that executes within a simple TransactionScope.

        using (var scope = new TransactionScope())
        {

            // does some logic.

            // then some more...

            scope.Complete();
        }

During execution an ado exception ocurres and the transaction is on it's way to being disposed.

In the mean time the exception is captured further upstream, and I try to log it to my database, via another connection.

At this point I get another error saying The operation is not valid for the state of the transaction.

Eeek!

Now I can see I am able to use IsolationLevel, to change the way my transactions interact, but is this the right thing to do? And which should I use?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ADO.NET