c# - 为什么使用 TransactionScope 的默认构造函数有害?

标签 c#

为什么使用 TranscationScope 的默认构造函数有害?

谁能指出我对此的解释?

最佳答案

请阅读 MSDN 博客上的这篇文章 using new TransactionScope() Constructor .

摘录:

The TransactionScope’s default constructor is, for the purposes of SQL Sever database programming, broken. TransactionScope’s default constructor defaults the isolation level to Serializable and the timeout to 1 minute. IMO both these settings are harmful when working against SQL Server.

The transaction timeout is bad because it’s obscure. A SqlCommand already has a CommandTimeout property that defaults to 30 seconds. If you explicitly extend the CommandTimeout on a SqlCommand, it’s probably unexpected that your transaction would timeout before that. But at least the timeout default can be changed in your application configuration file.

关于c# - 为什么使用 TransactionScope 的默认构造函数有害?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7198635/

相关文章:

c# - 根据公钥指数/模数进行 WinRT RSA 加密

c# - DropShadowExtender 和 RoundedCornersExtender 不能很好地与 ModalPopupExtender 配合使用

c# - 无法使用 Math.NET Numerics 从矩阵中删除行

c# - Console.ReadLine else-if 语句中的意外行为

c# - 如何下载asp.net文件中的json对象

c# - 在 Visual Studio 2008 for .NET CF 中处理不同的分辨率

c# - 让 Infragistics UltraWinGrid 在添加或删除行时调整高度

c# - 在方法调用中将函数隐式传递给 Func<> 时,您需要付出什么开销?

c# - 删除用户后 UserID 编号乱序

c# - 不能发送任何非通用类型的东西