TransactionIsolationLevel TransactionIsolationLevel TransactionIsolationLevel TransactionIsolationLevel Enum

Definizione

Specifica il valore di TransactionAttribute.Specifies the value of the TransactionAttribute.

public enum class TransactionIsolationLevel
[System.Serializable]
public enum TransactionIsolationLevel
type TransactionIsolationLevel = 
Public Enum TransactionIsolationLevel
Ereditarietà
TransactionIsolationLevelTransactionIsolationLevelTransactionIsolationLevelTransactionIsolationLevel
Attributi

Campi

Any Any Any Any 0

Il livello di isolamento del componente è ottenuto dal livello di isolamento del componente chiamante.The isolation level for the component is obtained from the calling component's isolation level. Nel caso del componente di primo livello, il livello di isolamento utilizzato è Serializable.If this is the root component, the isolation level used is Serializable.

ReadCommitted ReadCommitted ReadCommitted ReadCommitted 2

Sebbene durante la lettura dei dati vengano utilizzati blocchi condivisi per impedire la lettura dei dati modificati, è possibile apportare modifiche a tali dati prima della fine della transazione. Si otterranno pertanto letture non ripetibili o dati fantasma.Shared locks are held while the data is being read to avoid reading modified data, but the data can be changed before the end of the transaction, resulting in non-repeatable reads or phantom data.

ReadUncommitted ReadUncommitted ReadUncommitted ReadUncommitted 1

Sono attivati blocchi condivisi e vengono ignorati blocchi esclusivi.Shared locks are issued and no exclusive locks are honored.

RepeatableRead RepeatableRead RepeatableRead RepeatableRead 3

I blocchi sono posizionati su tutti i dati utilizzati in una query, impedendo l'aggiornamento dei dati da parte di altri utenti.Locks are placed on all data that is used in a query, preventing other users from updating the data. Impedisce le letture non ripetibili, ma è sempre possibile ottenere righe fantasma.Prevents non-repeatable reads, but phantom rows are still possible.

Serializable Serializable Serializable Serializable 4

Impedisce l'aggiornamento o l'inserimento fino a quando la transazione non è completa.Prevents updating or inserting until the transaction is complete.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato TransactionIsolationLevel l'utilizzo del tipo.The following code example demonstrates the use of the TransactionIsolationLevel type.

#using <System.EnterpriseServices.dll>

using namespace System;
using namespace System::EnterpriseServices;
using namespace 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 ref class IsolationAny : public 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 ref class IsolationReadCommitted : public 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 ref class IsolationReadUncommitted : public 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 ref class IsolationRepeatableRead : public 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 ref class IsolationSerializable : public ServicedComponent
{
};

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
{
}

Imports System.EnterpriseServices
Imports 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
    Inherits ServicedComponent
End Class

' 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
    Inherits ServicedComponent
End Class

' 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
    Inherits ServicedComponent
End Class

' 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
    Inherits ServicedComponent
End Class

' 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
    Inherits ServicedComponent
End Class

Si applica a