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

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.

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to register System.DirectoryServices for use in SQL CLR User Functions?(如何注册 System.DirectoryServices 以在 SQL CLR 用户函数中使用?)
Query From LDAP for User Groups(从 LDAP 查询用户组)
How can I get DOMAINUSER from an AD DirectoryEntry?(如何从 AD DirectoryEntry 获取 DOMAINUSER?)
Get a list of members of a WinNT group(获取 WinNT 组的成员列表)
Get UPN or email for logged in user in a .NET web application(在 .NET Web 应用程序中获取登录用户的 UPN 或电子邮件)
Active Directory Group Membership Checking in .Net 4.5(.Net 4.5 中的 Active Directory 组成员身份检查)