Suggestion “IManageProperties.GetChildren()”

Suggestion “IManageProperties.GetChildren()”

Old forum URL:

rxelizondo posted on Saturday, January 07, 2012


Every once in a while I need to create a method that requires information about the managed properties of the object.

For example, I may have a method called “ChangeRuleSet(string newRuleSet)” that is supposed to change the ruleset value of itself plus cascade the new ruleset  value to the children, the children’s children etc.

In cases like this, I wish I could have access to the “IManageProperties.GetChildren()” method so I could get a list of all the properties of the object. This way, I could easily identify what properties are csla collection and do a recursive call on them. Basically, something similar to what the  "BusinessRules.GetAllBrokenRules()" method does.

Any chance the method that implements the “IManageProperties.GetChildren()” contract method could be made public or protected? Or is there any other way to achieve similar functionality without having to reflect on the object?



JonnyBee replied on Sunday, January 08, 2012

Within a business object you can use

FieldManager.GetRegisteredProperties();     to get the registered properties.

FieldManager.GetChildren();                           to get the child properties.

The hard part when inspecting an object tree is to avoid triggering of LzyLoaded properties and possible exceptions when trying to read the field value of a lazy loaded field.

The actual implementation of IManageProperties.GetChildren is this in BusinessBase.cs:

    List<object> IManageProperties.GetChildren()
      return FieldManager.GetChildren();

You may also add public methods to your "sandwich" classes if you need to expose these values to the outside world.

Copyright (c) Marimer LLC