System.Transactions Spazio dei nomi
Contiene classi che consentono di scrivere un gestore personalizzato di risorse e applicazioni transazionali. Contains classes that allow you to write your own transactional application and resource manager. In particolare, è possibile creare una transazione (locale o distribuita) e prendervi parte con uno o più partecipanti. Specifically, you can create and participate in a transaction (local or distributed) with one or multiple participants.
Classi
CommittableTransaction |
Descrive una transazione di cui è possibile eseguire il commit.Describes a committable transaction. |
DependentTransaction |
Descrive un duplicato di una transazione che garantisce che non può essere eseguito il commit della transazione fino a quando nell'applicazione non si completano le operazioni relative alla transazione.Describes a clone of a transaction providing guarantee that the transaction cannot be committed until the application comes to rest regarding work on the transaction. La classe non può essere ereditata.This class cannot be inherited. |
DistributedTransactionPermission |
Autorizzazione richiesta da System.Transactions durante l'escalation del livello di gestione di una transazione a MSDTC.The permission that is demanded by System.Transactions when management of a transaction is escalated to MSDTC. La classe non può essere ereditata.This class cannot be inherited. |
DistributedTransactionPermissionAttribute |
Consente di applicare azioni di sicurezza per DistributedTransactionPermission al codice usando la sicurezza dichiarativa.Allows security actions for DistributedTransactionPermission to be applied to code using declarative security. La classe non può essere ereditata.This class cannot be inherited. |
Enlistment |
Facilita la comunicazione tra un partecipante alla transazione integrato e la gestione transazioni durante la fase finale della transazione.Facilitates communication between an enlisted transaction participant and the transaction manager during the final phase of the transaction. |
PreparingEnlistment |
Facilita la comunicazione tra un partecipante alla transazione integrato e la gestione transazioni durante la fase di preparazione della transazione.Facilitates communication between an enlisted transaction participant and the transaction manager during the Prepare phase of the transaction. |
SinglePhaseEnlistment |
Fornisce un insieme di callback che facilitano la comunicazione tra un partecipante inserito nell'elenco per il commit a una fase e la gestione transazioni quando viene ricevuta la notifica di SinglePhaseCommit(SinglePhaseEnlistment).Provides a set of callbacks that facilitate communication between a participant enlisted for Single Phase Commit and the transaction manager when the SinglePhaseCommit(SinglePhaseEnlistment) notification is received. |
SubordinateTransaction |
Rappresenta una transazione che non contiene una radice che può essere delegata.Represents a non-rooted transaction that can be delegated. La classe non può essere ereditata.This class cannot be inherited. |
Transaction |
Rappresenta una transazione.Represents a transaction. |
TransactionAbortedException |
Eccezione generata quando si è tentato di eseguire un'operazione in una transazione di cui è già stato eseguito il rollback oppure si è tentato di eseguire il commit della transazione e la transazione si interrompe.The exception that is thrown when an operation is attempted on a transaction that has already been rolled back, or an attempt is made to commit the transaction and the transaction aborts. |
TransactionEventArgs |
Fornisce i dati per i seguenti eventi di transazione: DistributedTransactionStarted e TransactionCompleted.Provides data for the following transaction events: DistributedTransactionStarted, TransactionCompleted. |
TransactionException |
Eccezione generata quando si tenta di operare in una transazione che non può accettare nuove operazioni.The exception that is thrown when you attempt to do work on a transaction that cannot accept new work. |
TransactionInDoubtException |
Eccezione generata quando viene tentata un'operazione su una transazione in dubbio oppure quando si tenta di eseguire il commit della transazione e questa diventa InDoubt.The exception that is thrown when an operation is attempted on a transaction that is in doubt, or an attempt is made to commit the transaction and the transaction becomes InDoubt. |
TransactionInformation |
Fornisce informazioni aggiuntive su una transazione.Provides additional information regarding a transaction. |
TransactionInterop |
Facilita l'interazione tra System.Transactions e i componenti che sono stati precedentemente scritti per interagire con MSDTC, COM+ o System.EnterpriseServices.Facilitates interaction between System.Transactions and components that were previously written to interact with MSDTC, COM+, or System.EnterpriseServices. La classe non può essere ereditata.This class cannot be inherited. |
TransactionManager |
Contiene i metodi utilizzati per la gestione delle transazioni.Contains methods used for transaction management. La classe non può essere ereditata.This class cannot be inherited. |
TransactionManagerCommunicationException |
Eccezione generata quando un gestore delle risorse non è in grado di comunicare con il gestore delle transazioni.The exception that is thrown when a resource manager cannot communicate with the transaction manager. |
TransactionPromotionException |
Eccezione generata quando una promozione ha esito negativo.The exception that is thrown when a promotion fails. |
TransactionScope |
Rende transazionale un blocco di codice.Makes a code block transactional. La classe non può essere ereditata.This class cannot be inherited. |
Struct
TransactionOptions |
Contiene informazioni aggiuntive che specificano i comportamenti di una transazione.Contains additional information that specifies transaction behaviors. |
Interfacce
IDtcTransaction |
Descrive una transazione DTC.Describes a DTC transaction. |
IEnlistmentNotification |
Descrive un'interfaccia che un gestore di risorse deve implementare per fornire i callback di notifica commit a due fasi per la gestione delle transazioni in seguito all'integrazione per la partecipazione.Describes an interface that a resource manager should implement to provide two phase commit notification callbacks for the transaction manager upon enlisting for participation. |
IPromotableSinglePhaseNotification |
Descrive un oggetto che svolge la funzione di delegato di commit per una transazione non distribuita interna a una gestione risorse.Describes an object that acts as a commit delegate for a non-distributed transaction internal to a resource manager. |
ISimpleTransactionSuperior |
Rappresenta una transazione non di primo livello, ma di cui è possibile eseguire l'escalation per consentirne la gestione mediante MSDTC.Represents a transaction that is not a root transaction, but can be escalated to be managed by the MSDTC. |
ISinglePhaseNotification |
Descrive un oggetto risorsa che supporta l'ottimizzazione mediante commit monofase per partecipare a una transazione.Describes a resource object that supports single phase commit optimization to participate in a transaction. |
ITransactionPromoter |
Descrive una transazione delegata di una transazione esistente di cui è possibile eseguire l'escalation per consentirne la gestione mediante MSDTC, se necessario.Describes a delegated transaction for an existing transaction that can be escalated to be managed by the MSDTC when needed. |
Enumerazioni
DependentCloneOption |
Determina il tipo di transazione dipendente da creare.Controls what kind of dependent transaction to create. |
EnlistmentOptions |
Determina se l'oggetto deve essere integrato durante la fase di preparazione.Determines whether the object should be enlisted during the prepare phase. |
EnterpriseServicesInteropOption |
Specifica il modo in cui le transazioni distribuite interagiscono con le transazioni COM+.Specifies how distributed transactions interact with COM+ transactions. |
IsolationLevel |
Specifica il livello di isolamento di una transazione.Specifies the isolation level of a transaction. |
TransactionScopeAsyncFlowOption |
Specifica se il flusso delle transazioni tra le continuazioni di thread è attivato per TransactionScope .Specifies whether transaction flow across thread continuations is enabled for TransactionScope. |
TransactionScopeOption |
Fornisce opzioni aggiuntive per la creazione dell'ambito di una transazione.Provides additional options for creating a transaction scope. |
TransactionStatus |
Descrive lo stato corrente di una transazione distribuita.Describes the current status of a distributed transaction. |
Delegati
HostCurrentTransactionCallback |
Fornisce un meccanismo affinché l'ambiente di hosting specifichi una propria nozione predefinita di Current.Provides a mechanism for the hosting environment to supply its own default notion of Current. |
TransactionCompletedEventHandler |
Rappresenta il metodo che gestisce l'evento TransactionCompleted di una classe Transaction.Represents the method that handles the TransactionCompleted event of a Transaction class. |
TransactionStartedEventHandler |
Rappresenta il metodo che gestirà l'evento DistributedTransactionStarted di una classe TransactionManager.Represents the method that will handle the DistributedTransactionStarted event of a TransactionManager class. |
Commenti
L' System.Transactions
infrastruttura rende la programmazione transazionale semplice ed efficiente in tutta la piattaforma, supportando le transazioni avviate in SQL Server, ADO.NET, MSMQ e Microsoft Distributed Transaction Coordinator (MSDTC).The System.Transactions
infrastructure makes transactional programming simple and efficient throughout the platform by supporting transactions initiated in SQL Server, ADO.NET, MSMQ, and the Microsoft Distributed Transaction Coordinator (MSDTC). Fornisce un modello di programmazione esplicito basato sulla Transaction classe, nonché un modello di programmazione implicito che utilizza la TransactionScope classe, in cui le transazioni vengono gestite automaticamente dall'infrastruttura.It provides both an explicit programming model based on the Transaction class, as well as an implicit programming model using the TransactionScope class, in which transactions are automatically managed by the infrastructure. Si consiglia di utilizzare il modello implicito più semplice per lo sviluppo.It is highly recommended that you use the easier implicit model for development. Per iniziare, vedere l'argomento implementazione di una transazione implicita mediante ambito di transazione .To get started, see the Implementing An Implicit Transaction Using Transaction Scope topic. Per ulteriori informazioni sulla scrittura di un'applicazione transazionale, vedere scrittura di un'applicazione transazionale.For more information on writing a transactional application, see Writing A Transactional Application.
System.Transactions
fornisce inoltre i tipi per implementare un gestore di risorse.System.Transactions
also provides types for you to implement a resource manager. Il gestore delle transazioni nativo per l' System.Transactions
infrastruttura consente di eseguire il commit o il rollback in modo efficiente delle risorse volatili o di un unico elenco di risorse durevoli.The transaction manager native to the System.Transactions
infrastructure allows volatile resources or a single durable resource enlistment to commit or roll back efficiently. Per ulteriori informazioni sull'implementazione di un gestore di risorse, vedere implementazione di un gestione risorse.For more information on implementing a resource manager, see Implementing A Resource Manager.
Il gestore delle transazioni inoltra inoltre in modo trasparente le transazioni locali alle transazioni distribuite mediante il coordinamento tramite una gestione transazioni basata su disco come DTC, quando un gestore di risorse durevole aggiuntivo si integra con una transazione.The transaction manager also transparently escalates local transactions to distributed transactions by coordinating through a disk-based transaction manager like the DTC, when an additional durable resource manager enlists itself with a transaction. Di base l'infrastruttura System.Transactions
utilizza due meccanismi per ottimizzare le prestazioni:There are two key ways that the System.Transactions
infrastructure provides enhanced performance.
Escalation dinamica, il che significa che l'
System.Transactions
infrastruttura attiva solo MSDTC quando è effettivamente necessaria per una transazione.Dynamic Escalation, which means that theSystem.Transactions
infrastructure only engages the MSDTC when it is actually required for a transaction. Questa area è illustrata in dettaglio nell'argomento escalation della gestione delle transazioni .This area is covered in depth in the Transaction Management Escalation topic.PSPE, che consente a una risorsa, ad esempio un database, di assumere la proprietà della transazione se è l'unica entità a parteciparvi.Promotable Enlistments, which allows a resource, such as a database, to take ownership of the transaction if it is the only entity participating in the transaction. In un secondo momento, se necessario, l'
System.Transactions
infrastruttura può ancora eseguire l'escalation della gestione della transazione a MSDTC.Later, if needed, theSystem.Transactions
infrastructure can still escalate the management of the transaction to MSDTC. Ciò consente di ridurre ulteriormente le probabilità di utilizzo del gestore MSDTC.This further reduces the chance of using the MSDTC. Questa area è analizzata in modo approfondito nell'argomento Ottimizzazione mediante commit a fase singola e notifica promuovibile a singola fase .This area is covered in depth in the Optimization Using Single Phase Commit and Promotable Single Phase Notification topic.
System.Transactions
definisce tre livelli di attendibilità che limitano l'accesso ai tipi di risorse esposti.System.Transactions
defines three levels of trust that restrict access on the types of resources it exposes. In particolare, l'assembly System. Transactions può essere chiamato da codice parzialmente attendibile perché è stato contrassegnato con l' AllowPartiallyTrustedCallers
attributo (APTCA).Specifically, the System.Transactions assembly can be called by partially trusted code as it has been marked with the AllowPartiallyTrustedCallers
attribute (APTCA). Questo attributo sostanzialmente rimuove il flag implicito LinkDemand dal set di autorizzazioni FullTrust
che altrimenti viene assegnato automaticamente a ogni metodo accessibile pubblicamente di ogni tipo.This attribute essentially removes the implicit LinkDemand for the FullTrust
permission set that is otherwise automatically placed on each publicly accessible method in each type. Tuttavia, alcuni tipi e membri richiedono comunque autorizzazioni di livello superiore.However, some types and members still require stronger permissions.
Di seguito è riportato un elenco di tipi e membri che non possono essere richiamati da codice parzialmente attendibile perché sono decorati con l'attributo di sicurezza dichiarativo seguente:The following is a list of types and members that are not callable by partially trusted code because they are decorated with the following declarative security attribute:
PermissionSetAttribute(SecurityAction.LinkDemand, Name := "FullTrust")
System. Transactions. Transaction. EnlistDurableSystem.Transactions.Transaction.EnlistDurable
System. Transactions. Transaction. EnlistPromotableSinglePhaseSystem.Transactions.Transaction.EnlistPromotableSinglePhase
System. Transactions. TransactionInteropSystem.Transactions.TransactionInterop
System. Transactions. TransactionManager. DistributedTransactionStartedSystem.Transactions.TransactionManager.DistributedTransactionStarted
System. Transactions. TransactionManager. HostCurrentTransactionCallbackSystem.Transactions.TransactionManager.HostCurrentTransactionCallback
System. Transactions. TransactionManager. reintegrateSystem.Transactions.TransactionManager.Reenlist
System. Transactions. TransactionManager. RecoveryCompleteSystem.Transactions.TransactionManager.RecoveryComplete
System. Transactions. TransactionScope. TransactionScope (System. Transactions. Transaction, System. TimeSpan, System. Transactions. EnterpriseServicesInteropOption)System.Transactions.TransactionScope.TransactionScope (System.Transactions.Transaction,System.TimeSpan,System.Transactions.EnterpriseServicesInteropOption)
M:System.Transactions.TransactionScope.TransactionScope (System. Transactions. TransactionScopeOption, System. Transactions. TransactionOptions, System. Transactions. EnterpriseServicesInteropOption)M:System.Transactions.TransactionScope.TransactionScope(System.Transactions.TransactionScopeOption,System.Transactions.TransactionOptions,System.Transactions.EnterpriseServicesInteropOption)
Per altre informazioni sui diversi livelli di attendibilità, vedere livelli di attendibilità per la sicurezza nell'accesso alle risorse.For more information on the various trust levels, see Security Trust Levels in Accessing Resources.
Sviluppo principale Base\accesso ai dati\Elaborazione elaborazione Core Development Technologies\Data Access\Transaction Processing\
Per ulteriori informazioni su come utilizzare lo System.Transactions
spazio dei nomi, è possibile consultare la documentazione concettuale relativa all' elaborazione delle transazioni, disponibile nella sezione "elaborazione principale di ai dati\Elaborazione per lo sviluppo base\Accesso \ " nella documentazione di.For more information on how to use the System.Transactions
namespace, you can consult the conceptual documentation Transaction Processing, located under the "Core Development Technologies\Data Access\Transaction Processing\" section in the documentation. In particolare, è possibile trovare altre informazioni negli argomenti seguenti.Specifically, you can find more information in the following topics.
Funzionalità fornite da System. TransactionsFeatures Provided By System.Transactions
Implementazione di un gestore di risorseImplementing A Resource Manager