Get SubTypes

Posts   
 
    
mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 17-Jun-2008 21:45:08   

Hi all,

Is there a ForEach statement to retrieve a list of subtypes from a supertype?

I like to iterate over a supertype's subtype so that I can generate the appropriate ServiceKnownType attribute declarations.

i.e.

<ServiceKnownType(MySubType1)> _ <ServiceKnownType(MySubType2)> _ <ServiceKnownType(MySubType3)> _ Public Class MyGeneratedSuperType

End Class

Thanks!

mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 17-Jun-2008 22:03:16   

The code below is sort of what I'm looking for:


<[If IsSuperType]>
    <[Foreach Entity]><[ If IsInHierarchyType TargetPerEntityHierarchy ]><[If IsSubType]><ServiceKnownType(GetType(<[CurrentEntityName]>))> _<[EndIf]><[EndIf]><[NextForeach]>
    <[EndIf]>

However, since I'm calling Foreach Entity, it's modifying the current entity context and causing the rest of my template to screw up. Any suggestions?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 18-Jun-2008 11:55:39   

I think the best thing you can do is to write an .lpt template instead of using TDL for this. TDL doesn't have a statement for this, so it's not useful for this type of thing, while in .lpt you can access anything you want.

To obtain all subtypes of a given entity, use in an .lpt template, the method GetSubTypes() on an EntityDefinition instance.

Frans Bouma | Lead developer LLBLGen Pro
mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 18-Jun-2008 17:08:55   

Otis wrote:

I think the best thing you can do is to write an .lpt template instead of using TDL for this. TDL doesn't have a statement for this, so it's not useful for this type of thing, while in .lpt you can access anything you want.

To obtain all subtypes of a given entity, use in an .lpt template, the method GetSubTypes() on an EntityDefinition instance.

Thank you Otis for the information simple_smile