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.
这篇关于单个事务下具有相同连接字符串的多个连接,提升事务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:单个事务下具有相同连接字符串的多个连接,提
基础教程推荐
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
