Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> CreateValidator
 

Pages: 1
LLBLGen Pro Runtime Framework
CreateValidator
Page:1/1 

  Print all messages in this thread  
Poster Message
pandu
User



Location:

Joined on:
18-May-2006 07:20:06
Posted:
86 posts
# Posted on: 09-Nov-2006 06:44:12.  
How do I add CreateValidator Class without touching the generated Entity Classes?

From Manual...
Quote:

Entity classes don't get a validator instance by default, even if you generate them through LLBLGen Pro. To automate the creation of an entity's validator object when you instantiate an entity, you should override the method CreateValidator in the entity class, either through a partial class, include template or by adding code to the custom code user code region of the generated entity classes.


Partial Class? How do I add partial class for EntityClass?

Thanks.

  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14639 posts
# Posted on: 09-Nov-2006 07:16:28.  
It's a .Net 2.0 feature:
Add new file containg the same class definition of the entity class in question but with the use of the keyword partial

Have a look at how the entity classes are defined in the generated code. You will find the keyword partial used.

Ref: http://msdn2.microsoft.com/en-US/library/wa80x488.aspx


  Top
pandu
User



Location:

Joined on:
18-May-2006 07:20:06
Posted:
86 posts
# Posted on: 09-Nov-2006 08:57:53.  
Ok.

I have created a new file with the following:

Code:
Partial Class SeasonEntity

    Protected Overrides Function CreateValidator() As IValidator
        Return Nothing
    End Function

End Class


SeasonEntity is my generated Entity Class. This gives me an error:

CreateValidator cannot be declared as Overrides.

I changed the Partial Class as:

Code:
#If CF Then
    <SD.LLBLGen.Pro.ORMSupportClasses.Serializable()> _
    Public Class SeasonEntity
#Else
<Serializable()> _
Partial Public Class SeasonEntity
#End If
    Inherits EntityBase2

    Protected Overrides Function CreateValidator() As IValidator
        Return Nothing
    End Function

End Class


This gives the following error:

Code:
Class 'SeasonEntity' must either be declared 'MustInherit' or override the following inherited 'MustOverride' member(s):
    SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2 : Public MustOverride Function GetDependentRelatedEntities() As System.Collections.Generic.List(Of SD.LLBLGen.Pro.ORMSupportClasses.IEntity2)
    SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2 : Public MustOverride Function GetDependingRelatedEntities() As System.Collections.Generic.List(Of SD.LLBLGen.Pro.ORMSupportClasses.IEntity2)
    SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2 : Public MustOverride Function GetMemberEntityCollections() As System.Collections.Generic.List(Of SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection2)
    SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2 : Public MustOverride Sub SetRelatedEntity(relatedEntity As SD.LLBLGen.Pro.ORMSupportClasses.IEntity2, fieldName As String)
    SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2 : Public MustOverride Sub SetRelatedEntityProperty(propertyName As String, entity As SD.LLBLGen.Pro.ORMSupportClasses.IEntity2)
    SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2 : Public MustOverride Sub UnsetRelatedEntity(relatedEntity As SD.LLBLGen.Pro.ORMSupportClasses.IEntity2, fieldName As String, signalRelatedEntityManyToOne As Boolean).    


Help please... Embarassed
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38092 posts
# Posted on: 09-Nov-2006 09:23:49.  
What's the llblgen pro version? In v2.0, CreateValidator is virtual, so your initial partial class is correct. So I think it's not recognized as a partial class of an existing class.

The second version you posted doesn't work as it inherits again from EntityBase2, a partial class is a second codefile for the same class. You therefore have to place it in the same namespace and PROJECT as the generated code. Did you do that?


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
pandu
User



Location:

Joined on:
18-May-2006 07:20:06
Posted:
86 posts
# Posted on: 10-Nov-2006 06:54:00.  
I was having that file outside the PROJECT where generated entity is.

I moved it inside the PROJECT and it works fine.

Thank you. Regular Smiley
  Top
Pages: 1  


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

Version: 2.1.12172008 Final.