Validation Problem with Child Objects

Validation Problem with Child Objects

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


Bonio posted on Monday, April 16, 2007

I have an Ediatable Root Object (Invoice) that holds a collection of line items (EditableChildList). (I have used the latest CodeSmith CSLA templates to generate the code).

I have set up custom validation in the root to check that lineitems exist.

When I ask the object to load an existing invoice and lineitems, it does so without problem, however the BrokenRules collection always states that there are no lineitems !!

Stepping through the code, it looks as if the "add custom rules" procedure is called before the object has loaded any data.

Anyone know how I can get this to work??

Thanks

Bone

Bonio replied on Monday, April 16, 2007

I think I have solved this issue:

 

I added a "ValidationRules.CheckRules()" in the DataPortal_Fetch method [shown below]:

 

private void DataPortal_Fetch(Criteria criteria)

{

using (SqlConnection cn = new SqlConnection(Database.CPFMangoConnection))

{

cn.Open();

ExecuteFetch(cn, criteria);

ValidationRules.CheckRules();

} //using

}

JoeFallon1 replied on Monday, April 16, 2007

I agree.

In my templates the last line of code for a Fetch is

ValidationRules.CheckRules()

Joe

 

Copyright (c) Marimer LLC