Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio .NET
Enterprise Samples
Duwamish 7.0
 Transaction Implementation

  Switch on low bandwidth view
Visual Studio Samples: Duwamish 7.0
Transaction Implementation

Transactions within Duwamish 7.0 are conducted in the Data Access layer. The Data Access layer is encapsulated by the Duwamish7.DataAccess assembly, which uses the System.Data.SqlClient namespace to access the Duwamish 7.0 database.

The Duwamish7.DataAccess classes are factored based on the type of data they manipulate as shown in the following table:

Class Function
Books Retrieves books by various attributes
Categories Retrieves book categories by various attributes
Customers Creates, retrieves and updates customer database entries
Orders Creates book orders

These classes operate on a single database. All transactions are local (non-distributed) to the Duwamish 7.0 database and run in stored procedures starting with a Begin transaction command and ending with an End transaction command or Rollback command. For more information, see BEGIN TRANSACTION Command, END TRANSACTION Command, and ROLLBACK Command.

Since explicit local transactions can be nested, it would be possible to compose new transactional functionality in either a new transactional stored procedure or the business logic layer using System.Data.SqlClient.SqlConnection.BeginTransaction and System.Data.SqlClient.SqlTransaction.Commit/Rollback.

Transacted stored procedures can be called either from a process already in a transaction or from processes that have no active transactions. The nested transactions are largely ignored, and the final action applies to the outer transaction. Specifically, committing inner transactions is ignored by Microsoft SQL Server. The transaction is either committed or rolled back based on the action taken at the end of the outermost transaction.

This is the recommended approach for a managed application, such as Duwamish 7.0, that does not have distributed transaction requirements. As a rule, nested local transactions yield better performance than distributed transactions executed by serviced components running under control of the Distributed Transaction Coordinator (DTC).

Note   The Fitch and Mather 7.0 sample demonstrates the use of distributed transactions. For more information, see Heterogeneous Distributed Transaction Implementation and Serviced Components.

Additional Reading

Gray, Jim and Reuter, Andreas. Transaction Processing: Concepts and Techniques (Morgan Kaufmann Series in Data Management Systems). San Francisco: Morgan Kaufmann Publishers, September 1992.

See Also

Architectural Overview | Data Access Strategy | Checkout | Nesting Transactions

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker