Multiple Connections With Same Connection String Under A Single Transaction, Elevated Transaction?

别来无恙 提交于 2019-12-18 07:06:23

问题


When using ado.net, and creating multiple connections to a MS SQL Server database within a single transaction (using System.Transactions.TransactionScope), does System.Transactions elevate the transaction from the lightweight transaction manager to the distributed transaction coordinator (kernel transaction coordinator on Vista), even if the connection strings are the same for all of the connection objects?

The documentation is somewhat ambiguous on this specific situation. It says the transaction will get elevated if another connection is opened to the server during the transaction but it doesn't say if it does that all the time or only if the connection string is different. It doesn't make sense to me that it would elevate the transaction if the connection string is the same, but if it does, it basically makes the lightweight transaction manager completely useless, IMO.


回答1:


In the current version it always elevates the transaction, unfortunately.

Which as you say, makes TransactionScope a lot less useful than it otherwise would be. I believe there are plans to change this in a future version.



来源:https://stackoverflow.com/questions/394702/multiple-connections-with-same-connection-string-under-a-single-transaction-ele

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