本文介紹了有沒有辦法將 TransactionScope 與現有連接一起使用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一些代碼的工作原理類似于 TransactionScope 的建議使用,但具有環境連接而不是環境事務.
I have some code that works like the advised use of TransactionScope, but has an ambient connection instead of an ambient transaction.
有沒有辦法將 TransactionScope 對象與現有連接一起使用,或者 .Net 框架中是否有替代方案?
Is there a way to use a TransactionScope object with an existing connection, or is there an alternative in the .Net framework for this purpose?
推薦答案
其實只有一種方法.
connection.EnlistTransaction(Transaction.Current)
它有效,如果沒有必要,它不會將交易提升為分布式(與文檔所說相反)
It works and it doesnt promote transaction to distributed if not necessary (contrary to what documentation says)
HTH
這篇關于有沒有辦法將 TransactionScope 與現有連接一起使用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!