using (var transaction = _context.BeginTransaction())
{
try
{
DO WHAT NEEDS TO BE DONE HERE
await _context.SaveChangesAsync();
transaction.Commit();
}
catch (Exception ex)
{
transaction.Rollback();
throw ex;
}
}
Instead of .SaveChangesAsync() you may just have .SaveChanges() and I bet you can imagine the difference.
No comments:
Post a Comment