O'Reilly logo

Professional C# 2008 by Karli Watson, Morgan Skinner, Jay Glynn, Bill Evjen, Christian Nagel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 22

Transactions

All or nothing — this is the main characteristic of a transaction. When writing a few records, either all are written, or everything will be undone. If there is even one failure when writing one record, all the other things that are done within the transaction will be rolled back.

Transactions are commonly used with databases, but with classes from the namespace System.Transactions, you can also perform transactions on volatile or in-memory-based objects such as a list of objects. With a list that supports transactions, if an object is added or removed and the transaction fails, the list action is automatically undone. Writing to a memory-based list can be done in the same transaction as writing to a database.

In Windows Vista, the file system and registry also get transactional support. Writing a file and making changes within the registry supports transactions.

In this chapter, the following topics are covered:

  • Overview of transaction phases and ACID properties
  • Traditional transactions
  • Committable transactions
  • Transaction promotions
  • Dependent transactions
  • Ambient transactions
  • Transaction isolation level
  • Custom resource managers
  • Transactions with Windows Vista and Windows Server 2008

Overview

What are transactions? Think about ordering a book from a web site. The book-ordering process removes the book you want to buy from stock and puts it in your order box, and the cost of your book is charged to your credit card. With these two actions, either both actions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required