Validation Rule on a parent collection?

Validation Rule on a parent collection?

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


NelsonF posted on Thursday, June 29, 2006

I need to make a validation rule for an object that compares it's data to other members of the collection it's in. For example, I have a collection of users, each has an groupid and an email property.
 
I need to insure that the groupid + email value is unique. I can do this as a constraint on the sql server, but all I get is a nice exception after I try to save instead of a warning message in the broken rules collection. Is there anyway to do this with the CSLA framework?
 
The RuleArgs doesn't seem to contain any reference to the collection the object belongs to so I'm not sure how I can iterate through the collection inside of a rule.
 
 

RockfordLhotka replied on Thursday, June 29, 2006

Each child object has a protected Parent property that you can use to gain access to the parent collection. If you implement your rule method as an instance method of the child class you should have access to this property.

Copyright (c) Marimer LLC