Yup, that's exactly what I ended up doing :)
On Mon, Jun 7, 2010 at 6:24 AM, Mauricio Scheffer
wrote:
> Ok, it seems that you have to override SqlType when you're using a custom
> database type. You can just write a generic class inheriting from
> EnumStringType and overriding SqlType and apply t
Ok, it seems that you have to override SqlType when you're using a custom
database type. You can just write a generic class inheriting from
EnumStringType and overriding SqlType and apply that one. See my updated
answer on stackoverflow.
On Mon, Jun 7, 2010 at 8:35 AM, Mike Christensen wrote:
>
I don't believe I explained the situation clear enough. The possible
values for the enum never change. It always must be one of those
values. However, which value it is can change. I have an enum called
OrderState which can be Preview, InQueue, or Completed. It can never
be anything else. I t
Yes. It will be a pain.. If those enums are never change then we dont need
to put them in database. I was in situation where we want to allow user to
add those values. For example: We have the project statuses (such as Not
Started, Started, Completed). We stored those values in database. User
shoul
These enums will never change. There's no reason to add more values
here (and if I ever do, I realize it'll be somewhat of a pain)..
On Sun, Jun 6, 2010 at 9:08 PM, Michael Sync wrote:
> I just check the Mauricio's answer on Stackoverflow.
> I have some confusions..
>>>public enum OrderState {In
Yup, overriding SqlType was the only way I could get it working.
Otherwise, the base EnumStringType class generates SQL statements with
the wrong cast. Something like:
INSERT INTO TestTable (State, Id) VALUES ('Preview'::text,
'9dea2a34-566a-45ea-84fd-24b86403ef5b'::uuid)
Which creates an error,
I just check the Mauricio's answer on Stackoverflow.
I have some confusions..
>>public enum OrderState {InQueue, Ordered, Error, Cancelled}
If we add one more row (one more OrderState) in Database, Is the enum
"OrderState" going to change automatically?
The reason that we want to keep the enum
Yep, that's pretty much what I answered on stackoverflow (
http://stackoverflow.com/questions/2979026/mapping-enums-to-database-with-nhibernate-castle-activerecord
, I just see it here). Is it really necessary to override the SqlType
property?
On Jun 5, 3:09 am, Mike Christensen wrote:
> Update:
Update:
Ok I found a kinda cleverish/hacky way of doing this. First off, I
only have one mapping class:
public class PgEnumMapper : NHibernate.Type.EnumStringType
{
public override NHibernate.SqlTypes.SqlType SqlType
{
get { return new NHibernate.SqlTypes.SqlType(DbType.Object); }
By default, an enum property gets mapped to an integer column type in
the database. I'm interested in mapping enums to an enum database
type, such as this one:
CREATE TYPE OrderState AS ENUM ('Preview', 'InQueue', 'Ordered',
'Error', 'Cancelled');
It seems you can fairly easily change ActiveReco
10 matches
Mail list logo