Custom code for new entity instances

Posts   
 
    
JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 20-Dec-2006 16:32:50   

As I've mentioned previously, I'm upgrading a project from LLBLGen 1.0, VB.NET 2003 to 2.0 and 2005

My old entity contained the code:

Public Sub New
    MyBase.New(New PropertyDescriptorFactory, New ReservationEntityFactory)
    ' __LLBLGENPRO_USER_CODE_REGION_START 
    SetDefaults()
    AddRules()
    ' __LLBLGENPRO_USER_CODE_REGION_END 
End Sub

But my newly generated code doesn't have a user code region. I understand I can't add my own, is this true? How can I add the SetDefaults functionality to this scenario but not all versions of calls to new i.e. I want the equivalent to:

Public Sub New(reservationId As System.Int32)
    MyBase.New(reservationId)
    ' __LLBLGENPRO_USER_CODE_REGION_START 
    AddRules()
    ' __LLBLGENPRO_USER_CODE_REGION_END 
End Sub
bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 21-Dec-2006 01:29:45   

I may not completely understand your scenario, but InitClassEmpty and if you're using SelfServicing InitClassFetch contain UserCodeRegions. Would these be suitable?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 21-Dec-2006 11:12:09   

That method isnt present anymore in v2.0 entites, as there's no longer a propertydescriptorfactory.

So you can safely ignore this method.

In v2.0 we added methods which are called when an entity is created, initialized etc. and which you can override in your code (e.g. in a partial class) and in which you can place your code, for example the calls to the routines you've placed in that constructor's region. Please see: "Using the generated code -> Tapping into actions on entities and collections" in the manual for details about this.

Frans Bouma | Lead developer LLBLGen Pro