How do I map enumeration type, say I have a Section class that has Category which is an enum. Section code is something like
Code:
/*
* Section.cs 0.1
*
* Copyright 2006 Ian Escarro. All rights reserved.
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
using System;
namespace Agta.ManilaBulletin.Data
{
/// <summary>
///
/// </summary>
public class Section : Observable
{
private int id;
private string title;
private string description;
private bool isInactive;
private Category category;
// private static Section instance = new Section();
// public static Section Instance
// {
// get { return instance; }
// }
public Section(int id, string title, string description,
bool isInactive, Category category)
{
this.Id = id;
this.Title = title;
this.Description = description;
this.IsInactive = isInactive;
this.Category = category;
}
public Section(int id) : this (id, "", "", false, Category.NewsAndFeatures) {}
/// <summary>
/// Creates a new instance of Section.
/// </summary>
public Section() : this (0) {}
public int Id
{
get { return id; }
set { id = value; }
}
public string Title
{
get { return title; }
set { title = value; }
}
public string Description
{
get { return description; }
set { description = value; }
}
public bool IsInactive
{
get { return isInactive; }
set { isInactive = value; }
}
public Category Category
{
get { return category; }
set { category = value; }
}
}
}
and my Enum Category
Code:
/*
* Category.cs 0.1
*
* Copyright 2006 Ian Escarro. All rights reserved.
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
using System;
namespace Agta.ManilaBulletin.Data
{
/// <summary>
///
/// </summary>
public enum Category
{
NewsAndFeatures,
KababayanEdition,
Hometown,
OwningAHome
}
}
and my Section.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
namespace="Agta.ManilaBulletin.Data" assembly="webartiData">
<class name="Section" table="Sections">
<id name="Id" column="SectionId" type="Int32">
<generator class="identity"/>
</id>
<property name="Title" column="Title" type="String"/>
<property name="Description" column="Description" type="String"/>
<property name="IsInactive" column="IsInactive" type="Boolean"/>
<!-- <TODO> for Category enum... -->
</class>
</hibernate-mapping>
Any help? Thanks in advance!