I am at the moment developping a project where the DAL is implemented in .Net using the ADO Entity Framework.
The DB structure is not straightforward and I would like to be able to ensure that some DB operations are atomic.
I know that you can do that by creating a STORED PROCEDURE
and using a DB TRANSACTION
(as mentioned in this SO post). (I'm using SQL Server)
The thing is, I would like to keep the logic on the software side as much as possible, and I was considering using .Net TransactionScope
. Although I understand that it works well from a software point of view (nothing is committed to the DB until the whole scope is committed), I doubt it still ensures DB atomic execution.
Does somebody know about this?
More specifically, usually the code would look like this:
using (TransactionScope scope = new TransactionScope())
{
/*
* Do some opreations such as reads, write, insert, deletes
*/
scope.Commit()
}
What I'd like to make sure, is that everything within the brackets is done "atomically" (isolation=SERIALIZABLE I guess). What I mean by that is that I don't want the state of the DB to be able to change when the code within the scope is executing.