Entity group name in templae

Posts   
 
    
cerberis
User
Posts: 93
Joined: 20-May-2011
# Posted on: 30-Mar-2015 15:32:42   

Hello,

is there any easy way to access group name of the entity in TDL template? Something like <[CurrentEntityGroupName]> ?

I would like to make namespaces for entities based on this. Is it possible?

I know about option to split project by groups, by I would like to keep single project but to have multiple namespaces.

regards Mantas

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 31-Mar-2015 05:16:51   

Having one project and different entity namespaces would be a hurdle. How would you keep track of namespace using for entities referencing other entities in other groups?

Otherwise, please check this relevant thread: https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=23172

cerberis
User
Posts: 93
Joined: 20-May-2011
# Posted on: 31-Mar-2015 08:59:52   

Not sure about what hurdle are you talking about, but we have a hurdle when we have to prefix entities with group name even if it might have same names in different namespaces. Not sure if that will not have other side effects in factories which resolves entity objects by entity names.. But for me it seems logical if I have 2 different schemas in my database which both have tables with the same name, why not to have entity with the same name?

Walaa wrote:

Having one project and different entity namespaces would be a hurdle. How would you jeep track of namespace using for entities referencing other entities in other groups?

Otherwise, please check this relevant thread: https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=23172

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 31-Mar-2015 21:37:26   

Do you have entities which have relations with other entities in a different schema?

cerberis
User
Posts: 93
Joined: 20-May-2011
# Posted on: 01-Apr-2015 06:42:28   

Yes, I have. Is this not allowed? simple_smile

Walaa wrote:

Do you have entities which have relations with other entities in a different schema?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Apr-2015 09:02:21   

It is not allowed, as grouping as separate projects generates separate independent DBGeneric VSNet projects.

David Elizondo | LLBLGen Support Team
cerberis
User
Posts: 93
Joined: 20-May-2011
# Posted on: 01-Apr-2015 09:06:56   

Well thats not allowed when generating separate projects which I would like to avoid. Thats why I would like to make grouping using namespaces in single project.

daelmo wrote:

It is not allowed, as grouping as separate projects generates separate independent DBGeneric VSNet projects.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Apr-2015 09:26:01   

I get it now. Well, it's possible. You need to create a custom template that replace the normal behavior. For more info check the SDK docs: http://www.llblgen.com/documentation/4.2/SDK/hh_start.htm

A related thread: https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=20439&StartAtMessage=0&#115196

BTW, What LLBLGen version are you using? and What is the target framework (LLBLG, NH, EF, etc)?

David Elizondo | LLBLGen Support Team
cerberis
User
Posts: 93
Joined: 20-May-2011
# Posted on: 01-Apr-2015 09:51:25   

Related thread points to nowhere simple_smile Yes, I tried to change template, but not sure how to access entity group name in entityAdapter.template file. I have tried to make lpt, but still dont know which entity variable name is used in outer cycle which generates entities simple_smile

LLBLGEn is the latest 4.2, February 16th, 2015. Target framework: LLBL

daelmo wrote:

I get it now. Well, it's possible. You need to create a custom template that replace the normal behavior. For more info check the SDK docs: http://www.llblgen.com/documentation/4.2/SDK/hh_start.htm

A related thread: https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=20439&StartAtMessage=0&#115196

BTW, What LLBLGen version are you using? and What is the target framework (LLBLG, NH, EF, etc)?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 01-Apr-2015 17:22:57   

In TDL it's not possible, you can in lpt. But that would mean you have to port the entity templates which are currently in tdl as well.

namespace <%=_executingGenerator.RootNamespaceToUse%>.<%=entity.GroupName%>.EntityClasses

Please check the designer reference manual available on the website (additional downloads or customer area) which describes the object model.

Frans Bouma | Lead developer LLBLGen Pro
cerberis
User
Posts: 93
Joined: 20-May-2011
# Posted on: 01-Apr-2015 17:45:54   

Cannot I do like this:

namespace <[RootNamespace]>.<# SD_EntityAdapterNamespaceTemplate #>.EntityClasses

And your code in SD_EntityAdapterNamespaceTemplate as lpt file?

I tried, but of course generator raises error saying that variable "entity" does not exists. Is there any way to get current entity name or entity object itself?

I really do not want to migrate whole template to LPT as it makes lots of troubles when migrating to the new version simple_smile

regards Mantas

Otis wrote:

In TDL it's not possible, you can in lpt. But that would mean you have to port the entity templates which are currently in tdl as well.

namespace <%=_executingGenerator.RootNamespaceToUse%>.<%=entity.GroupName%>.EntityClasses

Please check the designer reference manual available on the website (additional downloads or customer area) which describes the object model.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 03-Apr-2015 09:47:12   

No, you need to port the templates, which are indeed something I don't recommend at all.

The thing is that what you want isn't supported in the templates we ship, and adding it requires refactoring of the templates and that means custom changes.

There's another problem: the classes which refer to entities (like the factories) need to be updated as well, as they need to reference the entities of all namespaces you're generating.

So I'd advice against this. It's not supported and adding it will create a lot of work for you and in the future too for maintaining this codebase.

Frans Bouma | Lead developer LLBLGen Pro
cerberis
User
Posts: 93
Joined: 20-May-2011
# Posted on: 03-Apr-2015 09:51:35   

That's what I thought... However ability to access entity's group name using something like [<EntityGroupName>] would be great. Maybe in next release? simple_smile

regards Mantas

Otis wrote:

No, you need to port the templates, which are indeed something I don't recommend at all.

The thing is that what you want isn't supported in the templates we ship, and adding it requires refactoring of the templates and that means custom changes.

There's another problem: the classes which refer to entities (like the factories) need to be updated as well, as they need to reference the entities of all namespaces you're generating.

So I'd advice against this. It's not supported and adding it will create a lot of work for you and in the future too for maintaining this codebase.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 03-Apr-2015 09:55:48   

We'll think about it simple_smile

Frans Bouma | Lead developer LLBLGen Pro