Child Validation

Child Validation

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


Gigatron posted on Thursday, May 11, 2006

I'm having issues getting my child objects to use my business rules.  I'm a little confused as the ProjectTracker.Library doesn't really implement any child rules(if it does please point an example out if I'm mistaken), so I have no idea how this should work correctly.

I have the following in my root object:

Public Overrides ReadOnly Property IsValid() As Boolean
   
Get
      
Return MyBase.IsValid AndAlso mChildren.IsValid
   
End Get
End Property

I do get a Csla.Validation.ValidationException, but there is nothing in my Root objects BrokenRulesCollection.  Do I need to cycle through all my child objects and get their BrokenRuleCollection?  This seems like a pain in the butt to me.  Anyone have any idea's what could be wrong?

Gigatron replied on Thursday, May 11, 2006

What I was thinking was correct, I need to traverse my child objects to check their BrokenRulesCollection as well.  This is ok, and seems to make sense now.  lol

cvaron replied on Wednesday, June 14, 2006

Did you end up looping through all your child objects collections and creating a BrokenRuleCollection that contain all the broken rules for the parent and all it's child objects?

Is there a better way of doing this?

 

BigRon replied on Friday, June 09, 2006

I am currently experiencing the same frustration!  Let me know if you find anything on this.  The question is simply, what do we need to do to get the child objects to run business rule validation?

xal replied on Friday, June 09, 2006

BigRon, exactly, what is your problem? does your business object get saved in an invalid state?

If that is the case:
How are you adding your business rules?
What do you have (code) inside your property sets?
What do you have inside your root object's IsValid property?


Andrés

Copyright (c) Marimer LLC