Subsonic: Using SharedDbConnectionScope together with TransactionScope seems to be broken

◇◆丶佛笑我妖孽 提交于 2019-12-02 00:11:07

问题


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

回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/1242988/subsonic-using-shareddbconnectionscope-together-with-transactionscope-seems-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!