cslaforum icon indicating copy to clipboard operation
cslaforum copied to clipboard

Execute Rules in Children

Open CrossSlide opened this issue 5 years ago • 2 comments
trafficstars

Is there a way to CheckRules on All child BusinessObjects? I have some child rules that look to a parent value. If that parent value changes I need to execute the child rules. An OnParentChanged() event would work. Thanks

CSLA version: 4.6 OS: Windows Platform: WPF

CrossSlide avatar Mar 02 '20 17:03 CrossSlide

You must handle this in the parent object to call/execute rules on the cild items when the "parent" property has changed. F.ex override CheckPropertyRules

[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void CheckPropertyRules(IPropertyInfo property)
{
  var propertyNames = BusinessRules.CheckRules(property);
  if (ApplicationContext.PropertyChangedMode == ApplicationContext.PropertyChangedModes.Windows)
    OnPropertyChanged(property);
  else
    foreach (var name in propertyNames)
      OnPropertyChanged(name);
}

propertyNames will return all changed/affected properties in this validation.

jonnybee avatar Mar 03 '20 09:03 jonnybee

Thank you @jonnybee for the help!

CrossSlide avatar Mar 03 '20 10:03 CrossSlide