Suppose I have entity Person with properties typeid and salary. I build a business rule for this two properties like:
public static partial class MyRules
{
public static ValidationResult Rule1(Person p, ValidationContext context)
{
if ((p.typeid == 1) && ((p.salary == null))
{
return new ValidationResult("type 1 must should have salary",
new string[] { "Salary" });
}
return ValidationResult.Success;
}
}
The code is put at server side with share.cs.
So when the rule is violated, I wil have SubmitOperation.HasError = true; This kind of error only after call SubmitChanges. and the error does not display in ValidationSummary
So when SubmitOperation.HasError = true; how can I know SubmitOperation error is validation error not other error? When I can identify this error as validation error, how can I get the validation error message "type 1 must should have salary" and show it to user?