EntityType enum

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 08-Oct-2009 13:38:48   

I came across this issue and somehow I know I have raised it before on the forum.

The EntityType enum that is generated as part of the DAL starts its value from 0 (zero). I came across the case where some of my utility functions need to return an EntityType value or not.

The case of not would be most conveniant if used the value 0 (zero) that can easily be checked for.

Does it make sense to have the LLBL templates generate their enum values starting from 1 instead of 0 (zero) to cater for cases like this one ?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 09-Oct-2009 05:17:19   

Hi Omar, Why not use just nullable int? for your retun value?

David Elizondo | LLBLGen Support Team
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 10-Oct-2009 18:49:28   

Indeed thats a great idea. The downturn I see in int? approach:

1- (annoyance) The helper functions will return int? instead of the EntityType enum. This meanes consumers have to always check for null and then do the appropiate casting

2- (issue) some developers still tend to define a variable as EntityType and do not initialize it. This tends to introduce runt-time logical errors that could hard or tricky to catch specially in projects with multiple developer teams.

That said I do agree the int? is a viable option though having Unkown=0 as the first enum value is safer and more conveniant.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 11-Oct-2009 11:18:15   

I could add 'Unknown' or 'None' at position 0 in v3, that's not that much of a problem. Though for this purpose, IMHO int? is also an option, though agreed, nullable types are sometimes a pain to work with.

Frans Bouma | Lead developer LLBLGen Pro
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 11-Oct-2009 14:24:00   

Frans.. maybe you can add it a simple checkbox in v3 designer to handle the option of adding a zero value for the generated EntityType enum

mohamed avatar
mohamed
User
Posts: 136
Joined: 10-Mar-2008
# Posted on: 10-Mar-2011 22:37:30   

Otis wrote:

I could add 'Unknown' or 'None' at position 0 in v3, that's not that much of a problem. Though for this purpose, IMHO int? is also an option, though agreed, nullable types are sometimes a pain to work with.

Is there any news about this !!!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 11-Mar-2011 13:40:29   

No news, same as before.

Frans Bouma | Lead developer LLBLGen Pro