0
huntethan89 created
public void Execute(int Id)
{
string status = "";
try {
.............
.............
status = "Succeeded";
}
catch (Exception ex) {
status = "Failed";
}
finally {
_appService.Update(Id, status);
}
}
Update method -
public void Update(int Id, string status)
{
var record = _repository.Get(Id);
record.LastRunStatus = status;
_repository.Update(record);
CurrentUnitOfWork.SaveChanges();
}
The record is only updates if there is no exception in Execute method. I want the record to update even when there is exception. How can we achieve this?
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)
1 Answer(s)
-
1
Try using a new unit of work and transaction.
using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequireNew)) { //Insert or Update.. unitOfWork.Complete(); }Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)