Enumerations

Posts   
 
    
Posts: 37
Joined: 21-Oct-2004
# Posted on: 21-Oct-2004 21:01:52   

Searched around, but couldn't really find an answer to this, so I assume it's not possible yet. What I'd LOVE to have as a feature of this product is a way to define enums for text or numeric fields. Once the enum is defined, that field in the generated code would be represented by an enum type, but on the back end that enum would be translated to and from the database using (YourEnumType).ToString() and Enum.Parse(). In my previous data access layers that I've designed, I used Enums extensively to validate and limit user input. So far, this is the only thing I can't seem to do without a ton of modification to the generated code and custom casting in the business layer.

Any thoughts? To much of a pain in the butt to add as a feature, or is there already a way to do this?

wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 21-Oct-2004 21:30:59   

Check out the enum taskperformer in the 3rd party download section.

It takes a table and creates enum's from it. You just need to specify the value and name field.l

Posts: 37
Joined: 21-Oct-2004
# Posted on: 21-Oct-2004 22:50:55   

I'll take a look at it, thanks.

wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 22-Oct-2004 20:17:22   

In my previous data access layers that I've designed, I used Enums extensively to validate and limit user input

Be carefull with enums in dot net , as you can pass integer values that exceed the range of the enums and dot net will allow it and not complain. frowning - So it is not as usefull as it use to be to limit user input to valid values.

Some related threads:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=1125

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=1518

Posts: 37
Joined: 21-Oct-2004
# Posted on: 22-Oct-2004 20:51:26   

I've been using Enums simply as a way to get a Lookup list without having to define lookups anywhere else. Ie, generate a dropdownlist based on the text values in an enum (using .ToString()), then parsing that text value back into the field I want for the Enum. So from the user's perspective, it's only text being passed around. From the application's perspective, it's an enum.