NCC-1701-M wrote:
I have an old database which contains a column (Status) this column can have the values "New", "Assigned" or "Fixed".
I don't like to create a property which is a string. I'd like to create a enum
Instead of trying to expose a string property in your class, you might be better off doing something like this.
Create a new type to use in your mapping files. You only use this type in your mapping files, your business objects continue to use the Enum only.
Code:
using NHibernate.Type;
public class StatusTypeEnum : EnumStringType
{
public StatusTypeEnum()
: base(typeof(StatusType))
{ }
}
Once you have StatusTypeEnum class, you then use that in your mapping files like this:
Code:
<property name="Status" column="status" type="YourNameSpace.StatusTypeEnum, YourAssemblyName" />
The benefit to this is, you only have to create the StatusTypeEnum class once, and you can use it in all of your mappings.