Validation rules of the attributes do not work with webservice.
Ex :
BusinessRules.AddRule(new Required(CodPrestadorOperadoraProperty));
The field is required, but when I save generates the error
_Eleg.Save();
" Object is not valid and can not be saved "
I do not understand the actual issue here.
If the field has no value then the rule is broken, the object will have IsSavable = false and the Save method will give that exception.
Can you provide more details and code?
Hello Jonny,
This attribute is mandatory, the time I save should not prevent action stating that there is a required field and that it was not filled.
/////
Protected override void AddBusinessRules()
{
base.AddBusinessRules();
BusinessRules.AddRule(new Csla.Rules.CommonRules.Required (CodPrestadorOperadoraProperty , () => "Codigo Obrigatorio." ) );
BusinessRules.AddRule(new MaxLength(CodPrestadorOperadoraProperty, 10));
BusinessRules.AddRule(new MinLength(CodPrestadorOperadoraProperty, 2));
}
////
//// Save
_Eleg.CodPrestadorOperadora = null;
_Eleg = _Eleg.Save();
////
Using the WinForm, usually works.
Now the WebService that this rule does not bar.
When I use the "ErrorProvider", know what the error is.
When not use, do not know what error is.
Hi,
The business object is not aware of any type of UI or Service.
Csla is for business objects and not just data access code.
If the object has broken rules with severity ERROR the object is considered broken and you are not allowed to call Save.
An alternative is to change the Severity to Warning or Information. Any broken rule with these severities will NOT block Save operation.
Understand.
Thank you Jonny for the clarifications
Copyright (c) Marimer LLC