Transactions

Transactions are a critical feature for system reliability. Transactions are necessary when two or more activities must be coordinated as a single operation, ensuring that the system is always left in a consistent state. The only two viable options are to complete all activities successfully or to leave the system as it was before initiating eitheractivity.

The classic acronym to describe a transaction is that it must have ACID properties. ACID stands for the following:

Atomic

A transaction is an all-or-nothing proposition. Suppose a transaction issues an instruction to insert two database records? The two inserts must be completed as a single, atomic operation that either succeeds or fails.

Consistent

Transactions never leave the system in an inconsistent state. Suppose one of the inserts is completed and another caller sees the inserted record? If the transaction fails and that insert is reversed, the caller will have seen information that inaccurately represents the system state.

Isolated

Independent transactions operate separately until they complete their work. Suppose a second transaction attempts to insert to one of the same table records while the first transaction is in progress? The second transaction should be locked out until the first has completed, either successfully or not. There are other levels of isolation, but this strict option yields the best possible result in most cases.

Durable

No transaction should be lost. Suppose a machine goes down while a transaction ...

Get Learning WCF now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.