Enums revisited

Posts   
 
    
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 28-May-2005 00:41:11   

I have an enum declared for a lookup table that won't change (Status).

    
public enum POStatus
    {
        Draft = 1,
        SubmittedForApproval = 2,
        Approved = 3,
        Rejected = 4,
        Cancelled = 5,
        Issued = 6
    }

But my entity class of course has defined the property for this FK field as in int. So my BLL is full of code like this:

            
if ((POStatus)po.StatusID == POStatus.Draft)

I downloaded the task performer. First, it's not even clear t me how to get it to work. I followed the instructions on modifying the config file - but how do I tie it to a project? This task performer seems to apply to all projects??

Second, if it does what I think it's going to do, all it's going to do is save me a few minutes of typing up the enum structure. In order to get rid of these ugly casts all over the place, I need the property on the entity declared using my enum.

I've also searched all the previous threads on this subject.

Is there more to this? Is it even possible to do better here? confused

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 28-May-2005 11:43:02   

Which 3rd party download did you download exactly? The one with the plugin?

Frans Bouma | Lead developer LLBLGen Pro
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 28-May-2005 15:19:48   

Gen_Enums.*

Didn't realize there was more than one.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 30-May-2005 09:33:33   

JimFoye wrote:

Gen_Enums.* Didn't realize there was more than one.

Ah that one. I thought you perhaps were talking about the Lookup table plugin + templates.

It's my understanding it generates enums, but the value still has to be casted.

Frans Bouma | Lead developer LLBLGen Pro
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 31-May-2005 23:42:58   

I'm too lazy to try this myself so I'm just going to ask you stuck_out_tongue_winking_eye ...is it possible and reasonable to modify the derived classes to define the properties with my enum instead of ints?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 01-Jun-2005 10:42:03   

JimFoye wrote:

I'm too lazy to try this myself so I'm just going to ask you stuck_out_tongue_winking_eye ...is it possible and reasonable to modify the derived classes to define the properties with my enum instead of ints?

Not easy, as the TDL interpreter has to know which 'int' is an enum value and which one.

Frans Bouma | Lead developer LLBLGen Pro