Browse Source

`Rollback` if `SaveChanges` failed.

pull/14396/head
maliming 3 years ago
parent
commit
badb9b96d4
  1. 10
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs

10
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs

@ -98,7 +98,15 @@ public class AbpUowActionFilter : IAsyncActionFilter, ITransientDependency
var currentUow = unitOfWorkManager.Current;
if (currentUow != null)
{
await currentUow.SaveChangesAsync(context.HttpContext.RequestAborted);
try
{
await currentUow.SaveChangesAsync(context.HttpContext.RequestAborted);
}
catch (Exception e)
{
await currentUow.RollbackAsync(context.HttpContext.RequestAborted);
throw;
}
}
}

Loading…
Cancel
Save