Generate static properties

Posts   
 
    
Jowen
User
Posts: 47
Joined: 06-Feb-2007
# Posted on: 11-Mar-2010 11:50:15   

Hi,

I have a settings table with an Id and a Name column. I would like to generate static properties of the names for all the records in my table.

So if I would have a record with the name "ExampleSetting" I want to have a property available like this: SettingsEntity.ExampleSetting.

This way, I can't make typos in code, and feedback is given to me compile time...

any leads on how to achieve this? Should I create a custom template?

any help would be appreciated!

regards, Jowen.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 11-Mar-2010 12:03:07   

The same discussion was brought up here: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=13612 Speaking about enum values rather than static properties.

Jowen
User
Posts: 47
Joined: 06-Feb-2007
# Posted on: 11-Mar-2010 16:38:23   

It's not really comparable.

I'd rather not use the type converters; then I'd have a mapping between the names and their numeric value. I want my records to be location independent. (so the order of setting definitions is irrelevant).

what else would you recommend?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 11-Mar-2010 21:13:16   

You could download the enum converter mentioned in the above thread and use it as starting point to create your own generator task which emits the static data classes for you.

Matt

Jowen
User
Posts: 47
Joined: 06-Feb-2007
# Posted on: 12-Mar-2010 12:34:57   

but would I still need the converter?!

It makes more sense to write a task for this; and only a task...

that's why I want a tip or hint in the right direction, what to start with? simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 13-Mar-2010 10:56:57   

Jowen wrote:

but would I still need the converter?!

It makes more sense to write a task for this; and only a task...

that's why I want a tip or hint in the right direction, what to start with? simple_smile

You need the type converter in v2.6 to convert from enum value to db value (int, byte etc.) and vice versa. In v3 this is built in and you don't need a type converter anymore for enum types.

Frans Bouma | Lead developer LLBLGen Pro