Hi guys, today i tried to write my partial classes to do the validation on the fields and entity level. I am facing some problem with the following code that i had written (i m using self-servicing):
protected override void OnValidateEntityBeforeSave()
{
EmployeeEntity toValidate = new EmployeeEntity();
if (this.Name == null )
{
throw new ORMEntityValidationException("Name cannot be null", toValidate);
}
if (this.Address == null)
{
throw new ORMEntityValidationException("Address cannot be null", toValidate);
}
base.OnValidateEntityBeforeSave();
}
I wrote the following code to try out the overriden function above:
EmployeeEntity employee = new EmployeeEntity();
employee.EmpId = 19093;
employee.ValidateEntity();
I did not set any value for Name and Address for the employee entity,
however there is not error thrown when i execute the ValidateEntity() method.
Am i missing out something?
Thanks