Csla 1.1 and using TransactionScope

Csla 1.1 and using TransactionScope

Old forum URL: forums.lhotka.net/forums/t/6598.aspx


SeanRhone posted on Wednesday, March 11, 2009

My company won't give me the time to upgrade so we're still using Csla 1.1 but I put in a

using (transScope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
}

in a method that calls child business object for updating and I'm getting 'The operation is not valid for the state of the transaction" sometimes. Anyone know if there is a compatability issue between Csla 1.1 transactions and the newer .NET 2.0 TransactionScope?

It looks like all the child business objects updated correctly but I still get this error.

Thanks

tlong replied on Wednesday, March 11, 2009

We had something like this happening and it was due to not using the same connection for the child update as the parent.

Are you using the ContextManager (ala CSLA 3.x) or the ApplicationContext (ala CSLA 2.1.4) to pass the connection to the child?

 

SeanRhone replied on Wednesday, March 11, 2009

Nope still using Csla 1.1 for now.

tlong replied on Wednesday, March 11, 2009

I don't have a copy of 1.1 handy.  What's the pattern for a child update method?

RockfordLhotka replied on Wednesday, March 11, 2009

You must remember that your application is only running in the context of one version of .NET. So a TransactionScope is the same throughout your app, because you are only running one version of .NET.

(there was no TransactionScope in .NET 1.x btw, so there are obvious "compatibility issues" there :) )

Odds are that you are not using the same transaction scope or the same database connection across all your objects, and that's causing you the issue.

Copyright (c) Marimer LLC