You know what would be cool...

Posts   
 
    
worldspawn avatar
worldspawn
User
Posts: 321
Joined: 26-Aug-2006
# Posted on: 21-Jul-2009 05:34:10   

You know what would be cool... the ability to turn a table and it's data into an Enum via LLBL. For example if I have a table called "Status" and it has in it:

1, Pending, 2, Open, 3, Closed

Something like that, a simple name/value pair table of (almost) static values. It be great if I could tell LLBL to instead of making an entityclass it would just make an enum.

public enum Status
{
Pending = 1,
Open = 2,
Closed = 3
}

and then on, for example the hypothetical Project entity class we get:

public Status StatusUsingStatusId
{
get;//llbl voodoo goes here
set;
}

Main argument for this personally, is for these types of entities I often find myself writing code like - get status where name isn't 'Pending' or get me all of something where it's related status isn't 'Rejected'. Stuff like that. In that case I usually resort to caching the records in the table and doing a quick lookup to get the id of the status called 'Pending'.

But with the magic of enums I could be writing something like:

(from c in meta.Project where c.StatusId != (int)Status.Closed)

Now there could issues such as the id for 'Closed' being different on my dev db vs prod db... but those issues are easier to manage then all this stuff I have to do at the moment.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Jul-2009 07:37:28   

I think there is a 3rd party **Enum generator task performer **. Go to LLBLGen Site -> Customer Area -> v2.0 Donwloads -> 3rd Party -> Enum generator task performer.

I never used but I know people did. And I think It should work for 2.6. Give it a spin.

David Elizondo | LLBLGen Support Team