tags:

views:

449

answers:

2

Using the code below, the expected behavior is that the database won't reflect the update since ts.Complete() is never called but the updates seems to go through. But if I leave out the SharedDbConnectionScope then the expected behavior is seen. Is there a problem with SharedDbConnectionScope? Btw I am using Subsonic 2.2

using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())           
{
    using (TransactionScope ts = new TransactionScope())
    {                
        // update here
    }
}
+3  A: 

Found out the problem. The docs on Subsonic appears to be wrong. If I wrap TransactionScope over SharedDbConnectionScope then it works fine. The right way should be:

using (TransactionScope ts = new TransactionScope())
{
    using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())           
    {
            // update here
    }
}

Edit: As mentioned by firestorm, SharedDbConnectionScope doesn't seem to work in Subsonic 2.2. So the only solution seems to be to install MsDts and don't use SharedDbConnectionScope.

owcs
A: 

I don't think SharedDbConnectionScope works at all in Subsonic 2.2. The whole idea as far as I can see with the object is that when you use it you don't need to have MsDts installed on the server. I couldn't get this to work at all! When you install MsDts then you don't need SharedDbConnectionScope any more that's why your code works when it gets created after TransactionScope.

firestorm
I see. That would explain why the change would make it work
owcs