I have standarized all my LLBL data-access code to use the UnitOfWork but now I am facing the following issue;
1- entity (HRAnnualLeave) has an identity field (cntId)
3- the same uow object used to save the (HRAnnualLeave) entity is also used to save a (HRMonthlyAddition) entity
4- I want the (HRAnnualLeave) entity's identity value to be saved in a field in the (HRMonthlyAddition) entity
the code goes as follows:
'Me referes to the current instance of the HRAnnualLeave
uow.AddForSave(Me, refetch:=True)
Dim ma As HRMonthlyAddition = New HRMonthlyAddition
With ma
.StrEmployeeId = Me.StrEmployeeId
.IntLink = Me.CntId 'should get Me's identity value but gets zero!!
End With
uow.AddForSave(ma)
uow.Commit(adapter, True)
Now, I do want both save operations to execute in the context of the same transaction (both must pass or fail together) but I also want the identity value of (Me.cntId) to store in (ma.IntLink ) object!!
I guess I can commit the (Me) object to save and then get its identity value to store in the (ma) object but then I lose saving both entites in the same transaction