How to use transactions with the Entity Framework? -
When you have such a code:
something = something new (); BlahEntities b = new BlahEntities () b.AddToSomethingSet (some); B.SaveChanges ();
What extra work does the transaction work?
You can enter your code in the
field of transactions (Transaction Scope Scope = New Transaction ()) {// Your Code is scope.Complete (); // to commit. }
The TransactionScope System.Transactions are located in the namespace, which is located in the assembly of the same name (which you may have to manually add to your project).
Comments
Post a Comment