Many of my root objects are editable collections. I need collection wide rules for things like: Requiring unique names across child objects and requiring at least 1 item in the collection.
Can I put validation rules in a Editable Root Collection?
You can, but there's no support from CSLA because there's no support from data binding.
In other words, there's no sanctioned way to display rules from a collection in the UI - data binding simply doesn't have this concept.
Due to that, I didn't implement anything like ValidationRules in BusinessListBase, because the results couldn't be displayed.
But you most certainly can implement checks by overriding Save() and making sure the collection is valid before saving it - probably throwing a ValidationException if it is out of order.
Also, see this thread.
Rocky,
I checked out the thread, using the parent property to check the other entries makes sense to me. hen I try to use the parent property I get an exception because the parent property hasn't been set.
Does the CSLA set the parent property automatically or do I need to set it somewhere?
BusinessListBase automatically sets the parent property on the
child objects it contains.
If you have some other parent-child relationship then the
property is not automatically set, and you’ll need to implement you own
code in the parent to call SetParent() on the child.
Rocky
Copyright (c) Marimer LLC