Multiple Connections With Same Connection String Under A Single Transaction, Elevated Transaction?(单个事务下具有相同连接字符串的多个连接,提升事务?)
问题描述
当使用 ado.net 并在单个事务中创建到 MS SQL Server 数据库的多个连接(使用 System.Transactions.TransactionScope)时,System.Transactions 是否将事务从轻量级事务管理器提升到分布式事务协调器(Vista 上的内核事务协调器),即使所有连接对象的连接字符串都相同?
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?
文档在这种特定情况下有些含糊不清.它表示如果在事务期间向服务器打开另一个连接,则事务将被提升,但它没有说明它是一直这样做还是仅在连接字符串不同时才这样做.如果连接字符串相同,它会提升事务对我来说没有意义,但如果是这样,它基本上会使轻量级事务管理器完全无用,IMO.
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.
推荐答案
不幸的是,在当前版本中,它总是提升事务.
In the current version it always elevates the transaction, unfortunately.
正如您所说,TransactionScope 的用处比其他情况要少得多.我相信有计划在未来的版本中改变这一点.
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.
这篇关于单个事务下具有相同连接字符串的多个连接,提升事务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:单个事务下具有相同连接字符串的多个连接,提
基础教程推荐
- Moq It.Is<>不匹配 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- WPF 模态进度窗口 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
