>From memory, so it may be inaccurate:
NHibernate.Type.EnumStringType is the class you're interested in.
Usage:
[Property(ColumnType="NHibernate.Type.EnumStringType`1[[enumColors,
YOUR_ASSEMBLY]], NHibernate")]
public enumColors Color
{
get { return color; }
set { color = value; }
}
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Mike Christensen
Sent: Thursday, September 17, 2009 12:22 PM
To: Castle Project Users
Subject: Mapping PostgreSQL ENUM types to C# Enums
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---