C# – Subsonic: Using SharedDbConnectionScope together with TransactionScope seems to be broken

csubsonic

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
    }
}

Best Answer

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.