TDL Question

Posts   
 
    
GabeNodland avatar
Posts: 65
Joined: 31-Dec-2004
# Posted on: 10-Mar-2006 08:57:07   

Hello,

I am trying to create a predefined prefetch for all related entities using the following TDL code.


        Public Shared ReadOnly Property PrefetchAll() As IPrefetchPath2
            Get
                Dim prefetch As IPrefetchPath2
                prefetch = New PrefetchPath2(EntityType.<[CurrentEntityName]>Entity)
                
                <[ Foreach RelatedEntity ManyToMany]><[If Not MappedFieldRelationIsHidden]>
                prefetch.Add(<[CurrentEntityName]>Entity.PrefetchPath<[ MappedFieldNameRelation ]>)
                <[EndIf]> <[ NextForeach ]>
                <[ Foreach RelatedEntity ManyToOne]><[If Not MappedFieldRelationIsHidden]>
                prefetch.Add(<[CurrentEntityName]>Entity.PrefetchPath<[ MappedFieldNameRelation ]>)
                <[EndIf]> <[ NextForeach ]>
                <[ Foreach RelatedEntity OneToMany]><[If Not MappedFieldRelationIsHidden]>
                prefetch.Add(<[CurrentEntityName]>Entity.PrefetchPath<[ MappedFieldNameRelation ]>)
                <[EndIf]> <[ NextForeach ]>
                <[ Foreach RelatedEntity OneToOne]><[If Not MappedFieldRelationIsHidden]>
                prefetch.Add(<[CurrentEntityName]>Entity.PrefetchPath<[ MappedFieldNameRelation ]>)
                <[EndIf]> <[ NextForeach ]>
                
                Return prefetch
                
            End Get
        End Property

My first question, is there an easier way than specifying all of the different RelationTypes?

next, some entities have no relatedEnties that are visible, is there a way i can suppress this property from being in my output.

I am thinking that TDL is pretty powerful since all of the included templates are generated with this, but i suspect that i may need to switch to lpt.

Any suggestions are appreciated.

Thanks,
Gabe

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 10-Mar-2006 09:23:01   

In general, you're better of with .lpt templates, because you can do everything you want. TDL is used for the standard templates and only has features to make these templates work. TDL isn't a full blown language, it's a template language with pre-fab statements so debugging a template is very simple and easy. That has a downside: it's not as flexible as you'd like.

I think your code is what's required, perhaps even more statements. Though in .lpt templates you probably need more code to achieve the same effect, however you can write a utility method to perform a piece of logic so it might be more compact.

Frans Bouma | Lead developer LLBLGen Pro
GabeNodland avatar
Posts: 65
Joined: 31-Dec-2004
# Posted on: 10-Mar-2006 16:10:36   

thanks, lpt it is.