This project is read-only.

How do enumed tables work?

May 27, 2011 at 3:51 PM

I can't figure out how to create enums from tables.

I tried configuring a table as an enum ( IsTypeTable = true ) and it gave me a warning saying something like:

"For it to work, it needs a Name or a Description"

In the table i have those 2 columns under diferent names in portuguese (nome / descricao) so i configured in the model one of the columns to have the facade "Name" and the other for the facade "Description" but it still doesn't work.


Does the table needs to have the original names of the columns as "Name" or am i missing something?

May 28, 2011 at 1:18 AM

A type table maps an integer to a string. So it needs a primary key of an integer and then a name or description field for the string. You must then add some static data. The static data will be used to create the enumeration. So for example let's say you have a table "CustomerType" that has two fields "ID" and "Name", an integer and varchar. We then add data to the "static data" property list.

ID Name
1 BigFish
2 LittleFish
3 Unknown

Now when you generate the model an enum will be created with these values. You can then set the CustomerType property on the customer table with the enum.

var customer = ..(load some object)...
customer.CustomerTypeId = (int)CustomerTypeConstants.BigFish;

Jun 28, 2016 at 10:36 PM
Hey CodeTools,

Does this still work in the latest version I recently updated a project from 4.1 to this version and the code that deals with this is the next stumbling block for me.

Please advise.