CSLA 4 OnChildChanged SL4

CSLA 4 OnChildChanged SL4

Old forum URL: forums.lhotka.net/forums/t/9449.aspx


JJLoubser posted on Monday, August 30, 2010

is there any reason why the OnChildChanged will not work in CSLA 4 SL4?

//parent 

public partial class OrgStructureER : BusinessBase<OrgStructureER>
    {

protected override void OnChildChanged(Csla.Core.ChildChangedEventArgs e)

{

// not throwing

}

we change properties in this child:

private static readonly PropertyInfo<CompanyEC> CompanyProperty = RegisterProperty<CompanyEC>(p => p.Company, RelationshipTypes.Child);
        public CompanyEC Company
        {
            get
            {
                //if (FieldManager.FieldExists(CompanyProperty))
                    return ReadProperty(CompanyProperty);
                //else
                //    return null;

            }
            set
            {
                LoadProperty(CompanyProperty, value);
            }
        }

// child is a BusinessBase

I tried al the diffrent RelationshipTypes... not working ...

 

tmg4340 replied on Monday, August 30, 2010

OnChildChanged is designed to work with child collections.  You have a single instance of an object as a child.  In that case, CSLA won't manage that for you.  You have to hook into the change events yourself.

HTH

- Scott

JJLoubser replied on Monday, August 30, 2010

sorry scott your answer is incorrect, we test it with a normal TestER and TestChildEC, it works, but for our advance objects with ER to EC with ECL it is not working...

RockfordLhotka replied on Monday, August 30, 2010

Your failure scenario is:

BB (root) with BB (child) with BLB (child) with (BB) child

And when a child of the BLB is changed, the event doesn't cascade up to the root?

JJLoubser replied on Tuesday, August 31, 2010

Sorry guys, found my mistake, I used LoadProperty instead of SetProperty in my child objects. Everything works fine now. BB(root) with BB (child) with BLB(child) recursive works, BB(root) onChildChange works for all children BB(child) and BLB(child). 

Copyright (c) Marimer LLC