搜尋此網誌

2016-08-04

TransactionScope

EF6新增Database.BeginTransaction()
Working with Transactions (EF6 Onwards)
Entity Framework (EF) TransactionScope vs Database.BeginTransaction
Transaction Support in Entity Framework 6
What's the point of an explicit database transaction in Entity Framework 6?




使用前必需詳閱說明:
使用交易範圍實作隱含交易
根據預設,交易會在隔離等級設為 Serializable 時執行。在讀取頻繁的系統上,常常會選取使用 Serializable 以外的隔離等級。

11.TRANSACTION ISOLATION LEVEL *****
All About TransactionScope *****
What is default IsolationLevel for TransactionScope?
.NET TransactionScope and its default Transaction Isolation level issue

Transactions and Connections in Entity Framework 4.0 *****

using new TransactionScope() Considered Harmful *****

Why is System.Transactions TransactionScope default Isolationlevel Serializable

Deadlocks w/Entity Framework - how to rerun the transaction?
Quote from Ladislav Mrnka:
Default isolation level for TransactionScope is serializable which is the most restrictive level for transaction (= causes deadlock more often). You should start by using Read committed isolation level (but you must ensure that same data are not read multiple times from the database during a transaction) to reduce database locking but it will most probably doesn't solve the problem (it can reduce the frequency)


目前用法:
using (var ts = new TransactionScope(TransactionScopeOption.Required, 
     new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
{
     //TODO
     ts.Complete();
}




TimeOut 預設1分鐘,最大10分鐘。
All About TransactionScope *****
using new TransactionScope() Considered Harmful ***
Changing TransactionScope - Timeout at runtime
Transaction scope timeout on 10 minutes
Transactionscope timeout max is only 10 mins




Introducing System.Transactions in the .NET Framework 2.0

確保交易的新利器(TransactionScope)初體驗
KB-.NET 2.0 分散式交易新利器---TransactionScope
TransactionScope與COMMIT TRAN

.NET分散式交易程式開發FAQ
多重TransactionScope與TransactionScopeOption


Nesting Transactions with a Single SQL Server Database

[IIS] 啟用Microsoft 分散式交易協調器(MSDTC)服務




ORA-02089: COMMIT is not allowed in a subordinate session

與目前連接關聯的交易已完成,但尚未處置。必須先處置交易,才能使用連接來執行 SQL 陳述式。
The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements.
設定timeout

沒有留言: