Open GoogleCodeExporter opened 9 years ago
Original comment by bniemyjski
on 4 Mar 2011 at 8:07
Yes, This behavior with the IsValid property causes that validation process
will be performed two times, causing slow response in the UI layer (assuming
that you have a lot of records, let me say 200000), now load the records and
set this TList<T> of records as datasource in a GridView control with edit
feature enabled. You will see the red warning icon with the errors in the data
being retrieved in the grid. I think that IsValid property MUST to be verified
if and only if the IsDirty property is true. If you see the
EntityBaseCore.generated.cst file, the IsValid property call to Validate()
method, reviewing the code generated by templates, let me say Processors, first
call the Validate() method and next verify the result evaluating the IsValid
property, causing with this two validations. For solves this issue I wrote
following code in the EntityBase.cst template:
public override bool IsValid
{
get
{
if (IsDirty)
return base.IsValid;
else
return true;
}
}
Doing this override, you don't need to call the Validate() method, you only
evaluate the IsValid property.
Regards
César F. Qüeb Montejo
Senior Software Developer Engineer
MJJ Briliant, Inc
Original comment by cesar.q...@gmail.com
on 2 Feb 2012 at 3:53
Additional comments to my previous post:
Obviously you need to call the GetPaged() method to avoid retrieve all records
in the source, but let me say that I'm implementing this approach and the
performance is slow anyway. What if your entity requires five or ten rules for
validation?..
Check code in the ProcesorBase class, specifically in the Process() method that
drop in this issue (i.e. country entity):
public override IProcessorResult Process()
{
_country.AddValidationRuleHandler(ValidateIfCountryExists, "CountryExists");
// check country
_country.Validate();
if ( !_country.IsValid )
ProcessResult.AddBrokenRulesList(typeof(Entities.Country), _country.BrokenRulesList);
return ProcessResult;
}
Regards
Original comment by cesar.q...@gmail.com
on 2 Feb 2012 at 4:10
Original issue reported on code.google.com by
beriniw...@gmail.com
on 2 Mar 2011 at 7:16