IsolationLevel 列舉


指定交易的隔離等級 (Isolation Level)。Specifies the isolation level of a transaction.

public enum class IsolationLevel
public enum IsolationLevel
type IsolationLevel = 
Public Enum IsolationLevel


Chaos 5

無法覆寫來自隔離程度更深之交易的暫止變更。The pending changes from more highly isolated transactions cannot be overwritten.

ReadCommitted 2

在交易期間無法讀取 Volatile 資料,但可以修改該資料。Volatile data cannot be read during the transaction, but can be modified.

ReadUncommitted 3

在交易期間可以讀取和修改 Volatile 資料。Volatile data can be read and modified during the transaction.

RepeatableRead 1

在交易期間可以讀取 Volatile 資料,但無法修改該資料。Volatile data can be read but not modified during the transaction. 在交易期間可以加入新資料。New data can be added during the transaction.

Serializable 0

在交易期間可以讀取 Volatile 資料,但無法修改該資料,且不能加入新資料。Volatile data can be read but not modified, and no new data can be added during the transaction.

Snapshot 4

可以讀取 Volatile 資料。Volatile data can be read. 交易會在修改資料之前,先驗證在最初讀取資料後是否有另一個交易已變更該資料。Before a transaction modifies data, it verifies if another transaction has changed the data after it was initially read. 如果資料已更新,則會引發錯誤,If the data has been updated, an error is raised. 如此可允許交易回到先前所認可的資料值。This allows a transaction to get to the previously committed value of the data.

當您升級使用 Snapshot 隔離層級建立的交易時,會擲回具有錯誤訊息「無法升級 IsolationLevel 為快照的交易」的 InvalidOperationExceptionWhen you try to promote a transaction that was created with the Snapshot isolation level, an InvalidOperationException is thrown with the error message "Transactions with IsolationLevel Snapshot cannot be promoted".

Unspecified 6

使用與指定不同的隔離等級,但無法判斷該等級。A different isolation level than the one specified is being used, but the level cannot be determined. 如果設定這個值,會擲回例外狀況。An exception is thrown if this value is set.


受交易影響的資料稱為 volatile。The data affected by a transaction is called volatile. 當您建立交易時,可以指定套用至交易的隔離等級。When you create a transaction, you can specify the isolation level that applies to the transaction. 交易的隔離等級會決定在交易完成之前, 其他交易對變動性資料有何層級的存取。The isolation level of a transaction determines what level of access other transactions have to volatile data before a transaction completes.

最低隔離等級ReadUncommitted可讓許多交易同時在資料存放區上運作, 並不會因為造成作業中斷交易而造成資料損毀的保護。The lowest isolation level, ReadUncommitted, allows many transactions to operate on a data store simultaneously and provides no protection against data corruption due to interruptive transactions. 最高的隔離等級Serializable會針對造成作業中斷的交易提供高程度的保護, 但必須先完成每筆交易, 然後才允許任何其他交易對資料進行操作。The highest isolation level, Serializable, provides a high degree of protection against interruptive transactions, but requires that each transaction complete before any other transactions are allowed to operate on the data.

交易的隔離等級是在建立交易時決定。The isolation level of a transaction is determined when the transaction is created. 根據預設, System.Transactions基礎結構會Serializable建立交易。By default, the System.Transactions infrastructure creates Serializable transactions. 您可以使用交易的Transaction.IsolationLevel屬性來判斷現有交易的隔離等級。You can determine the isolation level of an existing transaction by using the Transaction.IsolationLevel property of a transaction.