TDL Token for destination schema?

Posts   
 
    
Kevinksy
User
Posts: 27
Joined: 05-Jun-2013
# Posted on: 23-Oct-2013 22:06:07   

I am upgrading an LLBLgen 2.0 project to 4.0. It makes extensive use of tdl templates to create DTO and interfaces. I have two schemas in the LLBL project and for whatever reason it was decided that in one schema DTO's would inherit from a custom IDTO and in the other schema they would inherit from a generic one.

Surprisingly this works except where one schema has a foreign key to a table in another schema.

private void InitFields()
{
// initialize related fields -- one to many
<[Foreach RelatedEntity OneToMany]><[If Not MappedFieldRelationIsHidden]>_<[CaseCamel MappedFieldNameRelation]> = new List <<[If StringValueEquals SourceSchemaName "APPBASE"]>I<[EndIf]><[RelatedEntityName]>DTO>();
<[EndIf]><[NextForeach]>
}

This snippet works when the source Entity and the destination entity is in APPBASE. If the source Entity is in APPBASE and the destination is in the other schema it causes some grief.

Is there a token like "SourceSchemaName" which knows the name of the destination schema? I tried "<[ElementTargetSchemaName]>" but it gives the same value as "SourceSchemaName"

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 24-Oct-2013 08:02:51   

SourceSchemaName is used when you loop through entity fields. ElementTargetSchemaName (quoting the docs) returns the schema name of the target of the current element. Element can be entity, typedview or stored procedure call. So I think you should use ElementTargetSchemaName.

Now, it seems to be not obvious what is the 'current element', the entity this template is running on, or the related entity in the loop. I will investigate this to give you a precise answer.

What is the target type of your template ('generic' or 'entity')? Could you attach your template, task and binding?

David Elizondo | LLBLGen Support Team
Kevinksy
User
Posts: 27
Joined: 05-Jun-2013
# Posted on: 25-Oct-2013 20:42:01   

Thanks for your help. I could not find a TDL token that would represent the destination schema name when a foreign key relationship is in a different schema.

It was easier to change the database foreign keys so that all keys to other tables were in the same schema.