单个事务下具有相同连接字符串的多个连接,提升事务?

9

本文介绍了单个事务下具有相同连接字符串的多个连接,提升事务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

当使用 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.

这篇关于单个事务下具有相同连接字符串的多个连接,提升事务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14

具有未知类型的 CreateDelegate
CreateDelegate with unknown types(具有未知类型的 CreateDelegate)...
2023-11-11 C#/.NET开发问题
5

Func<T>.BeginInvoke 使用线程池吗?
Does Funclt;Tgt;.BeginInvoke use the ThreadPool?(Funclt;Tgt;.BeginInvoke 使用线程池吗?)...
2023-11-11 C#/.NET开发问题
6

如何为具有空目标的实例方法创建委托?
How to create a delegate to an instance method with a null target?(如何为具有空目标的实例方法创建委托?)...
2023-11-11 C#/.NET开发问题
6