How do I add a CSLA Business Rule that depends on a property contained in the parent? #2803
-
I have a scenario where I need to access checkbox value (present in parent) in child which is a list |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
There are several ways to model this behavior. We favor mirroring the property value in the child class and make the parent class responsible for notifying the children when the value changes (if needed). Usually, the list will include a method for the parent to use, and the list handles iterating the children and updating them. You can use a managed property in the child class without defining a "regular" property. You would need a method to call SetProperty(), which allows the necessary rules to fire. Another option we use is to define a regular property with a public getter with a friend setter. |
Beta Was this translation helpful? Give feedback.
-
@hurcane Thanks for the suggestion, I'm going with your suggestion as |
Beta Was this translation helpful? Give feedback.
There are several ways to model this behavior. We favor mirroring the property value in the child class and make the parent class responsible for notifying the children when the value changes (if needed). Usually, the list will include a method for the parent to use, and the list handles iterating the children and updating them.
You can use a managed property in the child class without defining a "regular" property. You would need a method to call SetProperty(), which allows the necessary rules to fire. Another option we use is to define a regular property with a public getter with a friend setter.