ChicagoKiwi wrote:
Otis wrote:
Ok, so a selfservicing save call, which isn't recursive. I was under the assumption you used adapter, so that might caused my confusion a little. Though a non-recursive save on a different entity would never end up doing anything with project indeed...
I do use Adapter - sorry for the confusion - so the save is recursive. Saving the contract entity attempts to save the project as well. I only added the last point as additional information in case the method by which "needs validation" was determined is different for dependent entities for some reason.
Ok, then this is the reason: Your code:
currentProject = New MyProjectEntity(mainContract.ProjectId) // A
currentProject.IsNew = False // B
currentContract = New MyContractEntity(newId)
currentContract.project = currentProject // C
On line A you define a new project entity. You set the PK field to ProjectId. This is now changed.
On line B you set it to be a non-new entity, so this will have the effect of syncing currentProject.ProjectID with CurrentContract's FK.
As the PK of currentProject is set and changed, the project gets saved as it's assigned to currentContract and reachable from there.
Could you please verify if currentProject.Fields[(int)ProjectFieldIndex.ProjectId].IsChanged is true after B ?
(sorry for the late reply)