Broken Rules on BusinessListBaseBroken Rules on BusinessListBase
Old forum URL: forums.lhotka.net/forums/t/1869.aspx
MadGerbil posted on Wednesday, November 29, 2006
Business List Base doesn't support broken rules?
I've a collection that has children - but in order for the collection to be valid the children must add up to a certain number (on several properties). How do I do this if the BusinessListBase doesn't support any kind of validation?
ajj3085 replied on Wednesday, November 29, 2006
There are two ways to do this.
One is to override IsValid on the collection, which runs through the collection checking the 'collection rules.'
Another is to have a rule on the businessbase object, which knows its in a collection and checks the collection.
Andy
MadGerbil replied on Wednesday, November 29, 2006
Any practical recommendations either way?ajj3085 replied on Wednesday, November 29, 2006
It depends on what you need to do.
If you need a broken rule object to tell you why the collection is invalid, I would go the second route. If you just want to know without being able to obtain the details, the first method is just as valid.
Brian Criswell replied on Thursday, November 30, 2006
If the list is itself a child, the parent object could also have a a rule that is checked whenever one of the corresponding property of a child in the list changes.
ajj3085 replied on Friday, December 01, 2006
You could do that, but then you are coupling the parent to a particular child implementation. That's why I left that off my list; a class can know about itself, that's fine, and usually the collection class will only hold a particular concrete class anyway, so you're already coupled in that sense. I wouldn't recommend putting the rule in the parent though because of the coupling it would cause.
Copyright (c) Marimer LLC