List Validation

List Validation

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


acgritt posted on Tuesday, June 09, 2009

After perusing the forum posts, the general tack at the moment for validating items in a list (ie unique name across items) is to hook up an event handler to the Child List's CollectionChanged(silverlight) or ListChanged(.Net) event and to force the checking of the business rule for the property when that event gets fired.  However, my question is if anyone has a recommendation on how to handle this type of validation when the items themselves are Root objects in an EditableRootListBase.  I have the Validation rule on each business object so that it will go and check the Database to make sure it is unique there but how should I check it if in the UI the user is allowed to add multiple items to the list before saving all changes?

Adam Gritt

JoeFallon1 replied on Tuesday, June 09, 2009

You could create a container object for your ERLB. This container could be a standard BB object with its own rules. Since it contains the ERLB object it could have a rule that runs over the list and checks for uniqueness and prevents saving otherwise. This container is called various things (Unit of Work, Use Case Controller, etc.) It has a single factory method (create or fetch) and it instantiates all contained BOs. Save on the container gets you to the DataPortal where you can then save the contained objects. But if you go this far then why not just have a regular child collection? At least those objects won't try and save themselves as you edit them!

Joe

Copyright (c) Marimer LLC