Testing A Custom Property Value

Posts   
 
    
fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 19-Jun-2007 16:27:57   

Hi All,

What I would really like to do is set a custom property on each entity then emit code if that custom property is set to true, so I can skip certian entities when I need to. I looked for some example of this in the include templates but could not find anything. I am not sure if this has to be a TDL, or C#/VB.net language template or not. This is my first templete I want to create from scratch. Any help would be great.

Thanks,

Frank

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jun-2007 10:55:26   

There's no filtering mechanism in place for this at the moment, which skips certain entities based on meta-data in the entity.

Is this code which is in an include template, in a template which generates code for all entities into a single file or in a template which per entity generates a separate file?

Frans Bouma | Lead developer LLBLGen Pro
fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 20-Jun-2007 15:20:54   

Well, I would like it to generate a separate file for each entity. What I am trying to do is add some templates to my project that will generate some of the aspx/ascx files I need, but I don't necessary need them for every entity in the project. So I thought if I could use the custom properties at the entity level to tell the template engine when to generate this code that would work perfectly. I guess I could just let it generate for all entities and then just delete the ones I don't need.

Thanks,

Frank

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 20-Jun-2007 15:56:55   

It's a nice idea by the way.

But for now I think you'd have to generate for all and then delete the un-needed by hand.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jun-2007 22:24:29   

You could implement this, but with a customization to the template engine (The TDL engine or the .lpt engine, depending on the template type you're using). In there, you'll see a loop which loops over the entities for example. In that loop, you could check for a specified custom property and a specified value (which you specify via extra parameters of the task which are passed to the engine simple_smile ). It's alittle tricky but it might be helpful.

Frans Bouma | Lead developer LLBLGen Pro
arschr
User
Posts: 893
Joined: 14-Dec-2003
# Posted on: 21-Jun-2007 01:38:25   

Could the standard code be made to control the loop based on an optional delegate that would return true/false; if the delegate was not provided a true would be used?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Jun-2007 10:02:12   

How would you provide the delegate when the code generation cycle is started? simple_smile

Frans Bouma | Lead developer LLBLGen Pro
fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 21-Jun-2007 15:12:24   

I will probably just let it create for all of the entities then delete the ones I do not need, I would love to go in and try to update the source to make it work but I probably won't have time to get that done. Anyway, thanks for all the suggestions.

Frank

arschr
User
Posts: 893
Joined: 14-Dec-2003
# Posted on: 21-Jun-2007 15:20:08   

How would you provide the delegate when the code generation cycle is started?

I have no idea.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Jun-2007 19:02:20   

arschr wrote:

How would you provide the delegate when the code generation cycle is started?

I have no idea.

wink

Me neither. It's a tough problem, and solutions look simple until you come to the point of actually using them and then it doesn't seem possible...

Frans Bouma | Lead developer LLBLGen Pro