IsolationLevel IsolationLevel IsolationLevel IsolationLevel Enum

定义

指定事务的隔离级别。Specifies the isolation level of a transaction.

public enum class IsolationLevel
public enum IsolationLevel
type IsolationLevel = 
Public Enum IsolationLevel
继承
IsolationLevelIsolationLevelIsolationLevelIsolationLevel

字段

Chaos Chaos Chaos Chaos 5

无法覆盖隔离级别更高的事务中的挂起的更改。The pending changes from more highly isolated transactions cannot be overwritten.

ReadCommitted ReadCommitted ReadCommitted ReadCommitted 2

不可以在事务期间读取可变数据,但是可以修改。Volatile data cannot be read during the transaction, but can be modified.

ReadUncommitted ReadUncommitted ReadUncommitted ReadUncommitted 3

可以在事务期间读取和修改可变数据。Volatile data can be read and modified during the transaction.

RepeatableRead RepeatableRead RepeatableRead RepeatableRead 1

可以在事务期间读取可变数据,但是不可以修改。Volatile data can be read but not modified during the transaction. 可以在事务期间添加新数据。New data can be added during the transaction.

Serializable Serializable Serializable Serializable 0

可以在事务期间读取可变数据,但是不可以修改,也不可以添加任何新数据。Volatile data can be read but not modified, and no new data can be added during the transaction.

Snapshot Snapshot Snapshot Snapshot 4

可以读取可变数据。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 隔离级别的事务时,将引发 InvalidOperationException,并显示错误消息“无法提升快照隔离级别的事务”。When 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 Unspecified Unspecified 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.

注解

受事务影响的数据称为 "可变"。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.

适用于