Transactions are some statements with some work to be done wich must complete all successfully or all if one fail all must be drawn back.

Acid is a set of properties that guarantees that the transactions are executed reliable

if one part fails - everything fails
any transaction must leave the database is a valid state, anytime
ensures that the concurrent execution of transactions results in a system state like it was exectuted serially
if a transaction has been committed it will remain so, no way back

transactions come out of: system.transactions namespace. We know the following types of transactions:

Simple transactions
your applications write to a database and if everythings is inserted or updated the transactions is ok.
Distributed transactions
transactions with multiple connections of different type of connections

Isolation levels

there are two isolationlevel enums: one in and one in system.transaction. Both have the same values.Isolationlevel enum values.

transaction is executed according the isolatition level determined by the driver.
not supported in sql or oracle, pending changes from highly isolated transactions cannot be overwritten.
not shared locks, no exclusive locks, a dirty read of data can happen, undesirable.
shared locks are held, no dirty reads, data can be changed before the end of the transaction causing nonrepeatable reads.
locks are used on all data preventing other from updating any data.
a range lock is placed on a dataset. now one else can update until transaction is complete.
an effictive copy of data, one version can read while the other can update. the size can cause problems if overused.

Transactionscope lives in system.transactions. It has a mehtod: complete. This method you have to call when you are complete, it tells the transaction manager to commit all data. If it isn't called, or there is some kind of exception ( if transactionscope is ued with a using statement ) the transactions is rolledback. The transactionscope class can handle simple transactions and distributed full distributed transactions, depended of commands inside the using transaction statement. It automatically scales up from simple transaction to distributed transactions. Everything is rollbacked ( if the system supports rollbacked, fi a send email cannot be rolled back ). Example transactions scope:

using (TransactionScope CurrentScope = new TransactionScope())
catch (EntityCommandExecutionException)
	//Handle the exception as you normally would
	//It won't be committed so transaction wise you're done





Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!