Net Framework 2.0 Transaction Processing

Source: Internet
Author: User


Transactions

Transaction processing is an important aspect of building many business logic.



Transactions in. NET Framework 2.0

In. NET Framework 2.0 contains system. transactions, a new namespace that fully focuses on controlling transaction behavior. Developers usually use system. Transactions with an execution context, which is a new structure in. NET Framework 2.0. The execution context allows you to specify allCodeGeneral information, such as transactions. The following are applicationsProgramHow to use this method to combine a group of operations into a transaction example:

 
Using system. Transactions;
 
Using (transactionscope Ts = new transactionscope (required ))
{
// Perform operations, such as updating different DBMS
TS. Complete ();
}

Located inAll operations in the using block become part of a transaction because they share the transaction execution context defined by it. In this example, the last line calls the transactionscope complete method, which will cause the request to submit the transaction when exiting the block. This method also provides built-in error handling that terminates the transaction when an exception occurs.

As in this exampleTransactionscope specifies required, which means that the Code will always run as a part of the transaction: if the transaction of the caller exists, add it; if not, create a new one. As in enterprise services, you can specify other options, including requiresnew, supported, and notsupported.

With Enterprise Services and their predecessorsUnlike MTS and COM +, systems. Transactions fully focuses on controlling transaction behavior. For example, there is no need for a connection between the transaction and the internal state of the object. Enterprise Services require that an object be disabled when it ends the transaction, but systems. transactions does not.


The sqlclient provider in ADO. NET 2.0 is integrated with the new system. Transactions namespace to enable the behavior called upgradeable transactions. Although transact SQL can be used to start local or distributed transactions (begin transaction and begin distributed transaction), in some cases (especially in client/middle layer programming ), programmers may want to write components that can be used in one or more database solutions. These solutions may contain multiple SQL Server instances, and SQL server can automatically detect multi-instance access and "Upgrade" the transaction from local to multi-instance (distributed ). This is possible even when multiple database products or connections are used, provided that the first database (called Resource Manager in Distributed Transaction terms) is SQL Server. In ADO. net, upgradeable transactions are enabled by default.

Related information:


Http://editblog.csdn.net/msdncolumn/archive/2005/02/25/1658.aspx


Http://blog.joycode.com/kaneboy/archive/2005/02/15/44356.aspx


Http://idior.cnblogs.com/archive/2005/08/15/214300.html



Transaction team Wiki

Florin Lazar's blog

Jim Johnson's blog

Angle Saenz-badillos 'blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.