TDL [TypeOfField] returning blank

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 24-Mar-2007 21:58:02   

I am using the following TDL

<[Foreach RelatedEntity OneToMany]><[If Not MappedFieldRelationIsHidden]>

Public Shared Function GetRelated<[RelatedEntityName]>EntityCount( _
      <[Foreach RelationField Comma]>ByVal <[CaseCamel RelationFieldName]> _
      As <[TypeOfField]><[NextForeach]>) As Integer

...

In the generated code file I get the <[TypeOfField]> blank? Is there a different TDL command to get the typeOfField in this loop

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Mar-2007 04:32:30   

Please see this post and put attention to the highlight pkField.DotNetType.ToString(). http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=4846&HighLight=1

Hope helpful.

David Elizondo | LLBLGen Support Team
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 25-Mar-2007 15:47:53   

Thanx for the link.

the TDL loop <[Foreach RelatedEntity OneToMany]> is translated in lpt to this loop

<%
For Each relation As EntityRelation In currentEntity.Relations

     If relation.RelationType <> EntityRelationType.OneToMany Then
        Continue For
     End If
Next
%>

but what is the lpt counterpart of TDL's <[If Not MappedFieldRelationIsHidden]>

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39776
Joined: 17-Aug-2003
# Posted on: 26-Mar-2007 10:50:23   

omar wrote:

Thanx for the link.

the TDL loop <[Foreach RelatedEntity OneToMany]> is translated in lpt to this loop

<%
For Each relation As EntityRelation In currentEntity.Relations

     If relation.RelationType <> EntityRelationType.OneToMany Then
        Continue For
     End If
Next
%>

but what is the lpt counterpart of TDL's <[If Not MappedFieldRelationIsHidden]>

The trick is to peek into the TDLInterpreter sourcecode simple_smile . The interpret methods are named after the statement they handle, so it's pretty easy to find the code (single statement handler handles single TDL statements).

So you should peek into HandleIfMappedFieldRelationIsHiddenStart. There you'll see that it checks the current relation's UtilizingPropertyIsHidden property. The field mapped onto a relation is called internally the 'utilizing property', hence the name simple_smile

Also pay attention to the flag which signals if a relation is used for inheritance ('IsUsedForHierarchy), you should exclude these as well.

Frans Bouma | Lead developer LLBLGen Pro
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 26-Mar-2007 15:22:03   

Thanx Frans. I have to admit I did not expect that writing lpt templates would this much fun. I wrote a complete lpt template that generates GetRelatedxxxCount() functions for all 1:n related entities.

The SDK's deocumentation for the lpt made so much sense after seeing the lpt template posted in the link. I think it would have helped so much more if the SDK included a complete lpt template as a reference.