diff --git a/source/backend/dal/Repositories/CompensationRequisitionRepository.cs b/source/backend/dal/Repositories/CompensationRequisitionRepository.cs index 0d9fac216e..d0105f7e85 100644 --- a/source/backend/dal/Repositories/CompensationRequisitionRepository.cs +++ b/source/backend/dal/Repositories/CompensationRequisitionRepository.cs @@ -82,6 +82,7 @@ public bool TryDelete(long compensationId) { var deletedEntity = Context.PimsCompensationRequisitions .Include(fa => fa.PimsCompReqFinancials) + .Include(p => p.PimsPropAcqFlCompReqs) .AsNoTracking() .FirstOrDefault(c => c.CompensationRequisitionId == compensationId); @@ -92,6 +93,11 @@ public bool TryDelete(long compensationId) Context.PimsCompReqFinancials.Remove(new PimsCompReqFinancial() { CompReqFinancialId = financial.CompReqFinancialId }); } + foreach(var propAcqFile in deletedEntity.PimsPropAcqFlCompReqs) + { + Context.PimsPropAcqFlCompReqs.Remove(new PimsPropAcqFlCompReq() { PropAcqFlCompReqId = propAcqFile.PropAcqFlCompReqId }); + } + Context.CommitTransaction(); // TODO: required to enforce delete order. Can be removed when cascade deletes are implemented. Context.PimsCompensationRequisitions.Remove(new PimsCompensationRequisition() { CompensationRequisitionId = deletedEntity.CompensationRequisitionId });