Inheritance by changing the base entity name?

Posts   
 
    
Lakeman
User
Posts: 12
Joined: 15-Mar-2004
# Posted on: 04-Feb-2005 23:55:24   

We've been using LLBLGen Adaptor model for a while now and we're starting to have to add custom code to the generated code. I've read how to extend my entities by creating a MyOrderEntity class, but I've we've got a lot of code out there already that is using OrderEntity. I'd like to re-gen all of my code and create subclasses with names like OrderEntity, and have all the base entities have a name like OrderEntityBase. That way we can generate subclasses for all of the entities, and we don't have to go back and change our code to use new class names.

I've looked at the templates and there are quite of few templates that will have to change to accomplish this.

Does anyone have templates that do this? Has anyone tried to do this and have come up with a better approach?

Thanks

-Brian

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 05-Feb-2005 03:53:54   

I thought there were templates in the 3rd party section to do this?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39848
Joined: 17-Aug-2003
# Posted on: 05-Feb-2005 12:10:00   

No, the 3rd party section contains templates to generate a derived class per entity.

However, I think the problem is best solved using an include template for entityAdapter.template, in which you place code like:

<[If StringValueEquals CurrentEntityName "Order"]> <# CustomOrderCode #> <[EndIf]> <[If StringValueEquals CurrentEntityName "Customer"]> <# CustomCustomerCode #> <[EndIf]>

etc...

then, create per include a new file, add the code to that file and bind it to the template id you mentioned in the include file you'll bind to Custom_EntityAdapterTemplate, in a new template set config (based on an existing, so you can just add template bindings, see template studio tutorials).

This will bridge the time period until I've added the 'preserve user code in generated code' feature to the code generators in the upcoming upgrade which I hope will be finished (in beta) at the end of february.

Frans Bouma | Lead developer LLBLGen Pro
Lakeman
User
Posts: 12
Joined: 15-Mar-2004
# Posted on: 07-Feb-2005 17:18:29   

Devildog74 wrote:

I thought there were templates in the 3rd party section to do this?

There are 3rd party templates that do something close. I like that fact that it generates a subclass for every entity. The part I don't like is that the entity subclasses get a new name, instead of the entity base classes. I want the subclasses to have the same name as before, and the entity bases classes to have the modified name.

example...

EntityClasses: OrderEntity CustomerEntity

Entities after generating all entities with subclasses:

EntityClasses: OrderEntityBase CustomerEntityBase

EntitySubClasses: OrderEntity CustomerEntity

The templates in the 3rd party section do it this way:

EntityClasses: OrderEntity CustomerEntity

EntitySubClasses: MyOrderEntity MyCustomerEntity

See the difference?

-Brian