Sometimes the data we conducted many operations. If the code is wrong, it will lead to the implementation of part of the operation, and no part of the implementation of
This is certainly not acceptable. Either all executed or not executed whole. It is necessary to use the transaction;
Sql transactions are usually re-write (personally feel more difficult), but there are matters MVC is very simple: TransactionScope
It requires using System.Transactions namespace references
the code:
the using (the TransactionScope the TransactionScope new new TS = ())
{
. . . .
Written inside the need to perform logic operations
ts.Complete (); // Rollback
}
PS: If there is no reference to the package, can not import the namespace. NuGet need to find their own package