TransactionIsolationLevel Wyliczenie

Definicja

Określa wartość .TransactionAttribute

C#
[System.Serializable]
public enum TransactionIsolationLevel
Dziedziczenie
TransactionIsolationLevel
Atrybuty

Pola

Nazwa Wartość Opis
Any 0

Poziom izolacji składnika jest uzyskiwany z poziomu izolacji wywołującego składnika. Jeśli jest to składnik główny, używany poziom izolacji to Serializable.

ReadCommitted 2

Blokady udostępnione są przechowywane, gdy dane są odczytywane, aby uniknąć odczytywania zmodyfikowanych danych, ale dane można zmienić przed końcem transakcji, co powoduje nie powtarzalne odczyty lub dane fantomowe.

ReadUncommitted 1

Udostępnione blokady są wydawane i nie są honorowane żadne blokady wyłączne.

RepeatableRead 3

Blokady są umieszczane na wszystkich danych używanych w zapytaniu, co uniemożliwia innym użytkownikom aktualizowanie danych. Zapobiega powtarzalnym odczytom, ale wiersze fantomowe są nadal możliwe.

Serializable 4

Uniemożliwia aktualizowanie lub wstawianie do momentu ukończenia transakcji.

Przykłady

W poniższym przykładzie kodu pokazano użycie TransactionIsolationLevel typu .

C#
using System;
using System.EnterpriseServices;
using System.Reflection;

// References:
// System.EnterpriseServices

// An instance of this class will inherit its caller's transaction isolation
// level if available. If not, it will use isolation level Serializable.
[Transaction(Isolation=TransactionIsolationLevel.Any)]
public class TransactionAttribute_IsolationAny : ServicedComponent
{
}

// An instance of this class will read only committed data, but non-repeatable
// reads and phantom rows are still possible.
[Transaction(Isolation=TransactionIsolationLevel.ReadCommitted)]
public class TransactionAttribute_IsolationReadCommitted : ServicedComponent
{
}

// An instance of this class will read committed and uncommitted data, so dirty
// reads, non-repeatable reads, and phantom rows are possible.
[Transaction(Isolation=TransactionIsolationLevel.ReadUncommitted)]
public class TransactionAttribute_IsolationReadUncommitted : ServicedComponent
{
}

// An instance of this class will read only committed data and place shared
// locks on the data, preventing other users from modifying it, but other users
// can still insert rows into the data set, so phantom rows are still possible.
[Transaction(Isolation=TransactionIsolationLevel.RepeatableRead)]
public class TransactionAttribute_IsolationRepeatableRead : ServicedComponent
{
}

// An instance of this class will read only committed data and place a range
// lock on the data set, preventing other users from updating or inserting rows
// into the data set until its transaction is complete.
[Transaction(Isolation=TransactionIsolationLevel.Serializable)]
public class TransactionAttribute_IsolationSerializable : ServicedComponent
{
}

Dotyczy

Produkt Wersje
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1