TransactionScope:它变得更好了吗?

时间:2022-12-03
本文介绍了TransactionScope:它变得更好了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当 TransactionScope 首次出现时,我遇到了一些严重的问题,以使其在我的开发机器 (XP) 和我们的数据库服务器 (Windows Server 2003) 之间工作.

When TransactionScope first came out, I ran into some serious issues getting it to work between my dev machine (XP) and our database server (Windows Server 2003).

当我深入研究它时,这似乎是一个棘手且普遍的问题,有可能成为生产中的一个头疼问题,所以我决定不以这种方式处理事务(尽管我非常喜欢这种语法并且我真的很想让它工作).

When I looked into it more, this appeared to be a tricky and widespread issue that had a chance of becoming a headache in production, so I decided not to handle transactions this way (even though I like the syntax a lot and I really wanted it to work).

这些问题是否仍然存在,或者使用起来是否安全?你现在经常使用它没有问题吗?

Are these problems still out there or is this safe to use? Do you use this regularly now without issues?

非常感谢!

注意:已经很久了,但我认为这个问题与 Distribute Transaction Coordinator 有关.我摆弄了很长时间,但始终无法让它发挥作用.

Note: It has been a long time now, but I think the issue had something to do with Distribute Transaction Coordinator. I fiddled with it for a long time and was never able to get it working.

推荐答案

Rick Strahl 有一篇关于事务范围和 LINQ to SQL 的精彩博文 此处.它的上下文更像是 LINQ to SQL,但我认为有一些适用的原则可以帮助您解决问题.

Rick Strahl has a great post about transaction scope and LINQ to SQL here. Its context is more LINQ to SQL, but I think that there are some principles that apply which could help you solve your question.

为了更具体地回答您的问题,以下是 Strahl 对 TransactionScope 的看法:

to more specifically answer your question, here's what Strahl has to say about TransactionScope:

传统上 TransactionScope 是一个围绕分布式事务协调器 (DTC) 的 .NET 包装器,但它的功能有所扩展.一个问题是 DTC 在资源使用方面相当昂贵,并且它要求 DTC 服务实际运行在机器上(另一个服务在客户端安装时特别麻烦).

Traditionally TransactionScope was a .NET wrapper around the Distributed Transaction Coordinator (DTC) but it’s functionality has expanded somewhat. One concern is that the DTC is rather expensive in terms of resource usage and it requires that the DTC service is actually running on the machine (yet another service which is especially bothersome on a client installation).

但是,最近对 TransactionScope 和 SQL Server 客户端驱动程序的更新使得可以使用 TransactionScope 类及其提供的易用性,而无需 DTC,只要您针对单个数据库运行并使用单个一致的连接字符串

However, recent updates to TransactionScope and the SQL Server Client drivers make it possible to use TransactionScope class and the ease of use it provides without requiring DTC as long as you are running against a single database and with a single consistent connection string

这篇关于TransactionScope:它变得更好了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:C#/SQL 数据库侦听器 下一篇:.NET TransactionScope 类和 T-SQL TRAN COMMIT 和 ROLLBACK

相关文章

最新文章