Difference Between Transaction and TransactionScope

前端 未结 1 1061
一整个雨季
一整个雨季 2021-02-02 14:47

I am developing an application which communicates with an SQL Server 2005 database to execute some stored procedures. My client demands that all transactions be managed on the C

相关标签:
1条回答
  • 2021-02-02 15:33

    From msdn :

    The TransactionScope class provides a simple way to mark a block of code as participating in a transaction, without requiring you to interact with the transaction itself. A transaction scope can select and manage the ambient transaction automatically. Due to its ease of use and efficiency, it is recommended that you use the TransactionScope class when developing a transaction application. When you instantiate TransactionScope, the transaction manager determines which transaction to participate in. Once determined, the scope always participates in that transaction. The decision is based on two factors: whether an ambient transaction is present and the value of the TransactionScopeOption parameter in the constructor. The ambient transaction is the transaction within which your code executes. You can obtain a reference to the ambient transaction by calling the static Current property of the Transaction class.

    You can read more about that here :

    http://msdn.microsoft.com/en-us/library/ms172152(v=vs.90).aspx

    http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope(v=vs.90).aspx

    Great (a bit old) article about transaction in .NET 2.0

    http://msdn.microsoft.com/en-us/library/ms973865.aspx

    0 讨论(0)
提交回复
热议问题