I think I see the difference.
In 4.2, SetupSync* code generated in the entities looked something like this:
Private Sub SetupSyncProductSubtype(relatedEntity As IEntityCore)
If Not _productSubtype Is relatedEntity Then
DesetupSyncProductSubtype(True, True)
_productSubtype = CType(relatedEntity, ProductSubtypeEntity)
Me.PerformSetupSyncRelatedEntity( _productSubtype, AddressOf OnProductSubtypePropertyChanged, "ProductSubtype", Coda.Entities.RelationClasses.StaticPurchaseOrderItemRelations.ProductSubtypeEntityUsingProductSubType_IDStatic, True, New String() { } )
End If
End Sub
In 5.3, the code was refactored to do this:
Private Sub SetupSyncProductSubtype(relatedEntity As IEntityCore)
SetupSync(relatedEntity, _productSubtype, AddressOf OnProductSubtypePropertyChanged, "ProductSubtype", "", Coda.Entities.RelationClasses.StaticPurchaseOrderItemRelations.ProductSubtypeEntityUsingProductSubType_IDStatic, true, new String() { }, new Integer() { CInt(PurchaseOrderItemFieldIndex.ProductSubType_ID) })
End Sub
In the 5.3 case, _productSubtype is sent by reference. SetupSync looks like this:
protected void SetupSync<T>(IEntityCore relatedEntity, ref T member, PropertyChangedEventHandler handler, string fieldName, string fieldInRelatedEntity, IEntityRelation relation, bool connectToSaveEvent, string[] forfNames, int[] fkFieldIndexes)
where T : class, IEntityCore
{
if(member!=relatedEntity)
{
DesetupSync(true, true, ref member, handler, fieldName, fieldInRelatedEntity, relation, true, fkFieldIndexes);
member = (T)relatedEntity;
this.PerformSetupSyncRelatedEntity( member, handler, fieldName, relation, connectToSaveEvent, forfNames );
}
}
The problem here is that this.PerformSetupSyncRelatedEntity calls OnPropertyChanged, but the passed reference (member) has not been resolved back to _productSubType until the function is complete. So, if my overridden OnPropertyChanged code depends on _productSubType being set (as it was in 4.2), I'm in a bit of a bind.
I should probably use "ProductSubType" as the fieldName instead of "ProductSubType_ID" in OnPropertyChanged anyway. I realize there's not much you guys can do here, but I thought I'd let you know that there is a difference in behavior between the versions. Not really looking forward to going through all of my OnPropertyChanged methods, but it's probably cleaner in the long run.
Thanks.