Transaction Processing
Transactions are managed and coordinated by the Transaction Manager. Each resource that affects the transaction result is managed by a resource manager. The transaction manager communicates with the resource manager to define the transaction results.
ADO. NET transactions do not support cross-connection transactions. They are always associated with local transactions on a connection.
Using System. enterpriseServices the advantage of using transactions is that you do not need to perform explicit Transaction processing. The runtime automatically creates transactions. You only need to add the [Transaction] feature to classes that have Transaction processing requirements. The [AutoComplete] feature marks the method as the automatic setting of the Transaction Status bit: if the method is successful, it sets the successful BIT. Therefore, the transaction can be committed. If an exception occurs, the transaction is terminated. One advantage of using System. EnterpriseServices to create a transaction is that multiple objects can be easily run in the same transaction, and the transaction can be automatically registered. The disadvantage is that it requires the COM + host model. The class using this technology must be derived from the base class ServiceComponent.
System. Transactions
CommittableTransaction is the only transaction class that supports submission. This class has a Commit method, and all other transaction classes can only perform rollback. The DependentTransaction class is used for transactions dependent on other transactions. Dependent transactions can depend on the transactions created from the committed transactions.
System. transactions supports upgradeable transaction processing. When multiple SqlServer database connections are added to the transaction, this upgrade is performed. The transaction starts as a local transaction and then is upgraded to a distributed transaction. To upgrade a transaction, you must start the Distributed Transaction Coordinator (DTC ). If a transaction fails to be upgraded in the system, verify that the DTC service is started,
One of the major advantages of System. Transactions is that environmental Transactions do not need to be registered manually using connections. This is automatically implemented in resources that support environmental Transactions.
One way to create an environment Transaction is to create a CommittableTransaction object and assign it to the Transaction. Current attribute to initialize the environment Transaction. Another way to initialize environment transactions is to use the TransactionScope class. The constructor of the TransactionScope class creates an environment transaction.
To use the same environment transaction in another thread, you need to use the dependent transaction.