Why is it harmful to use 开发者_如何学编程TranscationScope
's default constructor?
Can someone point me to explanation of this?
Please read this article on the MSDN blog using new TransactionScope() Constructor.
Excerpt:
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.
精彩评论