Sometimes you may wish to make a series of database calls in Entity Framework, but may need to reverse these calls if any single one fails. This can be accomplished using TransactionScope and try/catch.
try
{
using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.RequiresNew, transOptions))
{
// EF calls here
transaction.Complete();
}
}
catch
{
throw;
}
No comments:
Post a Comment