Recursive validation

Posts   
 
    
Fab
User
Posts: 108
Joined: 20-Oct-2008
# Posted on: 24-Oct-2008 16:04:57   

Hi

I'm converting my projects from old llblgen (2005.1 I think) + .net 1.1 to the lastest llblgen version (2.5) + .net 2.0 (yeah, 3.5 is for later)

Previously, I had to do a trick to have all validation errors at once, before the save. I mean: - Normal llblgen behaviour: just before an entity save, it validate the data, and if it's not correct it throw an exception. In this behaviour, the client try to save (via webservices), got an exception (on entity A), the user fix this validation error, submit again and ... got a new validation error on entity B (because entity B is saved only if entity A is saved). - My trick : code to recursively execute the validation method on all linked entities ( using GetDependentRelatedEntities / GetDependingRelatedEntities / GetMemberEntityCollections)

So my question now: Is it a way to do it easier in version 2.5 ? Or an easy way than to use these 3 methods called recursively with loop check etc. ?

I've search on the forum but didn't find anything...

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Oct-2008 05:05:49   

Hi Fab,

I think your approach is very straight-forward. If you throw exceptions at your validators that's what happens.

What you could do is either:

A) What you are doing right now: At AValidator, call the dependingEntities validator routines that return true or false.

B) Set the IDataErrorInfo for the entities that didn't pass the validate routine. So, at BValidator you could check if AEntity comes with errors.

Also it's recommended that you validate client-side things like format input, max and min values, etc. That way you could avoid unnecessary roundtrips.

Hope this was helpful.

David Elizondo | LLBLGen Support Team
Fab
User
Posts: 108
Joined: 20-Oct-2008
# Posted on: 27-Oct-2008 10:02:13   

Yes I allready do basic validation on the client side too.

But is there any method that can give me the whole list of entity that will be involved in the save process ? It could be easier (and maybe more efficient) to use the existing method to parse the graph instead of reading all properties/collection.

It's strange that nobody asked this functionality before (validate all entities recursively) as it's something that can be very usefull simple_smile . But it's also my fault, I could ask it a long time before but as I added it myself... didn't think about anymore simple_smile

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 27-Oct-2008 12:15:55   

But is there any method that can give me the whole list of entity that will be involved in the save process ?

Try the DetermineActionQueues() method of the ObjectGraphUtils class.

Fab
User
Posts: 108
Joined: 20-Oct-2008
# Posted on: 28-Oct-2008 19:13:23   

It works fine ! Tx for your help