I believe I have come across a discrepancy as to how SetParent is called and how an object is marked as a parent or child of another object. I ran across this because of our particular implementation. I had a Property Info defined as follows:
Note: I am using 184.108.40.206 of CSLA
private static readonly PropertyInfo<IProduct> _ProductProperty = RegisterProperty<IProduct>(p => p.Product);
In the actual property we Lazy Load the Product. Product is a CSLA object but we expose it as a IProduct because the parent object is exposed as an interface to the UI layer. When we call LoadProperty the Parent property is not set for the Product. It is set correctly though after the parent object is saved. Looking through the CSLA Source I believe I have found the where the issue/discrepancy lies.
In Csla\Core\BusinessBase.cs -- LoanPropertyValue the following code exists:
Obviously our IProduct does not inherit from IEditableBusinessObject even though Product does. This code is different through from the code used in Csla\Core\BusinessBase.cs -- FieldDataDeserialized. The logic in this method, including FieldManager.GetChildren() use the is and as operators to check if the object inherits from IEditableBusinessObject.
Was this implementation intentional as it seems rather inconsistent. After a save the Product returned from the property has the Parent set correctly but before the same it does not. I was able to work around the issue by changing our implementation to use Product in the PropertyInfo and then implement an explicit interface property to expose the IProduct.
Also, I did check the latest codebase for CSLA and the code still exists the same as it did in 220.127.116.11 for this logic.
Copyright (c) Marimer LLC