IsolationLevel |
serializable, flag |
System.Data (system.data.dll) |
enum |
This enumeration specifies the isolation level that is used for a
transaction. The isolation level is a measure of the degree that a
transaction is isolated from other database activity. Higher
isolation levels provide better data integrity, but they also slow
performance because of required locking. For example, the highest
isolation level, Serializable , places a lock on
all the tables a transaction accesses, which prevents other users
from updating or inserting rows while the transaction is in process.
Their requests are still processed when the transaction ends,
provided their commands don't time out.
RepeatableRead is the next highest isolation
level; it uses locking to prevent another user from updating or
deleting the rows that are being used in the transaction, but it
doesn't guarantee that new rows
won't be inserted. ReadCommitted
is often a good compromise with shared locks held while the data is
being read, thereby avoiding dirty reads (reads that retrieve
information from a transaction that has not yet been committed).
However, the data can be changed by another user before the end of
the transaction, resulting in nonrepeatable reads or phantom data.
This is SQL Server's default.
ReadUncommitted doesn't use any
locking, and dirty reads are possible.
You specify the isolation level when creating a transaction with the
IDbConnection.BeginTransaction( ) method. Not all
providers support all levels (for example, Chaos
isn't supported by SQL Server).
public enum IsolationLevel {
Chaos = 0x00000010,
ReadUncommitted = 0x00000100,
ReadCommitted = 0x00001000,
RepeatableRead = 0x00010000,
Serializable = 0x00100000,
Unspecified = 0xFFFFFFFF
}
Hierarchy
System.Object
System.ValueType System.Enum(System.IComparable, System.IFormattable
, System.IConvertible)
IsolationLevel
Returned By
IDbTransaction.IsolationLevel
, System.Data.OleDb.OleDbTransaction.IsolationLevel
, System.Data.OracleClient.OracleTransaction.IsolationLevel
, System.Data.SqlClient.SqlTransaction.IsolationLevel
Passed To
IDbConnection.BeginTransaction( )
, System.Data.OleDb.OleDbConnection.BeginTransaction( )
, System.Data.OleDb.OleDbTransaction.Begin( )
, System.Data.OracleClient.OracleConnection.BeginTransaction( )
, System.Data.SqlClient.SqlConnection.BeginTransaction( )
|