Execute Business rule on child object When Parent property has change.

Execute Business rule on child object When Parent property has change.

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

patelravij@gmail.com posted on Monday, March 12, 2012

I have parent root(Mater) object as BusinessBase which has BusinessListBase(ChildList) object as a child.

Parent (BusinessBase)

    - Child List (BusinessListBase)

                - Child (BusinessBase)

I have a custom business rule implemented in child object (BusinessBase of ChildList), which depends on parent root(Mater) property. Now when parent root(Mater) property is changed, how to notify child object?

There is override method OnChildChanged which fires when any child property changed. Is there any way to fires custom rules on child object and show property status when parent property has been changed?

JonnyBee replied on Monday, March 12, 2012

You can override PropertyHasChanged in parent object and rerun rules for child objects when that specific property has changed.

PropertyHasChanged will only be called when property content has changed.

patelravij@gmail.com replied on Monday, March 12, 2012

Thanks JonnyBee for prompt reply

I have override PropertyHasChanged in parent object. But how can I check business rules for each child in ChildList?
I have tried below two methods for check business rules.
BusinessRules.CheckRules() and  BusinessRules.CheckObjectRules(). But it does not fire business rules for child objects and does not update property status.

So can you please guide me how to rerun business rules for each child in Child List so than custom business rules execute and property status is updated?

JonnyBee replied on Monday, March 12, 2012

you can extend the child object with a "CheckAllRules" that notify UI of changes like this:

    public void CheckAllRules()
      var propertyNames = BusinessRules.CheckRules();
      if (ApplicationContext.PropertyChangedMode == ApplicationContext.PropertyChangedModes.Windows)
        foreach (var name in propertyNames)

 And call this in from the PropertyHasChanged in the root object.


patelravij@gmail.com replied on Wednesday, March 14, 2012

I have tried your sugestion and Its worsk. Thanks a lot....

Michael Waihenya replied on Friday, March 30, 2012


I have an interface IGrandChildList that all lists implement to expose the Parent and override the SetParent method of the child object. I thenadd a handler OnParentChanged that will allow me to execute my rules.

Protected Overrides Sub SetParent(parent As Csla.Core.IParent)
            AddHandler DirectCast(parent, IGrandChildList).GetParent.PropertyChanged, AddressOf OnParentChanged
End Sub
Protected Overridable Sub OnParentChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs)
            ' Check Rules here

End Sub

Copyright (c) Marimer LLC