Hi, I have a customer entiry and want to call my validations on entity before save, so what i have done is
- this is my config file
<section name="dependencyInjectionInformation" type="SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionSectionHandler, SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=3.1.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27"/>
<dependencyInjectionInformation>
<additionalAssemblies>
<assembly filename="MyProject.Data.Validation.Validators.dll"/>
</additionalAssemblies>
</dependencyInjectionInformation>
- created a seperate project and added a class for validation below is the code for that class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SD.LLBLGen.Pro.ORMSupportClasses;
using MyProject.Data.DatabaseSpecific;
using MyProject.Data.EntityClasses;
using MyProject.Data.FactoryClasses;
using MyProject.Data.HelperClasses;
using MyProject.Data.Linq;
using MyProject.Data.RelationClasses;
namespace MyProject.Data.Validation.Validators
{
[DependencyInjectionInfo(typeof(CustomerEntity), "Validator")]
public class CustomerEntityValidator:ValidatorBase
{
public override void ValidateEntityBeforeSave(IEntityCore involvedEntity)
{
CustomerEntity entity = new CustomerEntity();
if ((entity.FirstName == null) || (entity.FirstName == string.Empty))
{
throw new ORMEntityValidationException("First Name cant be null", entity);
}
base.ValidateEntityBeforeSave(involvedEntity);
}
}
}
Dont know when I am calling the save method of adapter its not coming into here, please help.
Thanks
Khurram