chore: update package versions and refactor TransactionBehavior
- Upgrade EF Core packages to 10.0.x and HrynCo.DAL.Abstract to 1.0.10 - Refactor TransactionBehavior to simplify transaction handling logic
This commit is contained in:
@@ -18,11 +18,15 @@ public class TransactionBehavior<TRequest, TResponse> : IPipelineBehavior<TReque
|
||||
|
||||
public Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken) =>
|
||||
_profiler.MeasureExecutionAsync(
|
||||
() => _unitOfWork.ExecuteInTransactionAsync(async () =>
|
||||
async () =>
|
||||
{
|
||||
TResponse response = await next();
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
return response;
|
||||
}),
|
||||
TResponse? response = default;
|
||||
await _unitOfWork.ExecuteInTransactionAsync(async () =>
|
||||
{
|
||||
response = await next();
|
||||
});
|
||||
|
||||
return response!;
|
||||
},
|
||||
typeof(TRequest).Name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user