Mapping Enum in Nhibernate

I make it short :

I have a object Post and a property “PostType”.

This property is an enum type and I want to map it in nhibernate with the string values for the enum items.

  public enum EnumPostType
    {         Question, BlogPost     }
Post Entity enum property:
  public virtual EnumPostType PostType { get; set; }
Mapping :
  Map(x => x.PostType).Column("PostType").CustomType(typeof(PostType));
To save the string values of the enum items :
  public class PostType : EnumStringType<EnumPostType>     {     }
That’s it Smile

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s