为什么使用 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/