Rule on Collection

Rule on Collection

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


renegrin posted on Tuesday, September 11, 2007

I want to put a rule on a collection to validate whether the collection is empty or not. I have business case where I need to ensure a child record exists before a parent record is saved. How should I accomplish this? Can the parent see the childList's count property in a broken rule?

skagen00 replied on Tuesday, September 11, 2007

I'd probably place the validation rule on the parent object, attach it to the property name equal to that of the collection's property name - and then attach an event handler to the collection's listchanged event - at which point I would raise PropertyHasChanged for the property name (on the parent) -- the validation rule attached would simply look at the count of the collection and determine it's broken status.

i.e. your broken rule doesn't exist on the collection persay - it's a broken rule for parent of the collection. Collections don't have the capacity for having broken rules themselves.

 

JoeFallon1 replied on Wednesday, September 12, 2007

Ditto.

The BO that contains the collection should have the rule.

Copyright (c) Marimer LLC