Log in


   Active Threads  

You are here: Home > LLBLGen Pro > Generated code> Adapter validator is not working - DI

Pages: 1
Generated code
Adapter validator is not working - DI

  Print all messages in this thread  
Poster Message


Joined on:
26-Nov-2011 22:47:16
166 posts
# Posted on: 07-Dec-2011 19:22:19.  
Hi, I have a customer entiry and want to call my validations on entity before save, so what i have done is

1. this is my config file

<section name="dependencyInjectionInformation" type="SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionSectionHandler, SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27"/>

            <assembly filename="MyProject.Data.Validation.Validators.dll"/>

2. 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);


Dont know when I am calling the save method of adapter its not coming into here, please help.

Support Team

Guatemala City
Joined on:
28-Nov-2005 23:35:24
7905 posts
# Posted on: 08-Dec-2011 03:39:18.  
Check these points:

1. If you are using a Web application you must use the fullname assembly as stayed in the Docs:
Docs wrote:
Auto-discovery doesn't work in website applications most of the time, so you should define Dependency Injection configuration settings in the web.config file as defined in the Manual discovery through dependencyInjectionInformation sections in the .config file below. You then also should specify the assemblies with the fullName attribute and the assembly's full name, instead of the file name like in the following example.
<assembly fullName="MyAuditorAssembly, Version=, Culture=neutral, PublicKeyToken=null"/>

This is necessary because the reference to the assembly with the Dependency Injection classes isn't there, as the pages are often compiled in separate assemblies. After deployment, it might be that the references are there, but that's not always the case. Better is to define this in the config file using the dependencyInjectionInformation section.

When the injectable types are defined inside the webapplication however, the auto-discovery works.

2. Although this seems obvious, please double check that your validator assembly is reachable by your application. In other words, make sure you referenced the project in your app, or that the assembly is copied to the app's output bin folder.

David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
Pages: 1  

Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.