Mike Christensen
unread,Sep 17, 2009, 2:21:46 PM9/17/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Castle Project Users
In ActiveRecord, I can easily map a column to an enum..
enum enumColors {Green, Blue, Red};
[Property(NotNull = true)]
public enumColors Color
{
get { return color; }
set { color = value; }
}
In the DB, it creates an integer column type and green is stored as 0,
blue is stored as 1 and red is stored as 2. This is fine. However, I
want to take advantage of Postgres ENUM types:
CREATE TYPE colors AS ENUM ('Green', 'Blue', 'Red);
ALTER TABLE Foo ADD COLUMN Color colors;
Now I have a DB type called colors and a column in the table Foo
called Color which is of type colors. The question is how do I map my
class to this data type? ActiveRecord appears to want to read/write
the data as an integer, and Postgres returns it as a string. Any
ideas? Thanks!
Mike