This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, This is occurring in LightSpeed 5 (we're using the build from 2 April 2013, but we've reproduced the same issue in the latest nightly build). It involves code contained within a transaction scope, i.e.
If this is the only interaction with the UoW, everything works fine and any exceptions thrown after the initial SaveChanges cause the transaction to be rolled back. But, if the code interacts with the UoW before entering the transaction scope (e.g. performing a query or an update within another TransactionScope), the TransactionScope seems to be ignored. All changes are saved even if an exception is thrown, and from SQL Profiler you can see that there are no BEGIN, COMMIT or ROLLBACK transaction statements. I've attached a VS2010 unit test project demonstrating the behaviour. Does this seem wrong, or have I misunderstood how TransactionScope is intended to behave? |
|
|
Yes there is a misunderstanding here about the behavior of a TransactionScope. When we make a connection from the UnitOfWork we will get enlisted into any ambient transaction scope, but if you start the scope after the connection was established then it will be ignored. More simply put just ensure your transaction scope is wider than your UnitOfWork scope. Alternatively you can call UnitOfWork.BeginTransaction to manually start a new transaction.
|
|