Hi,
i had a need to create enum like classes for lookup tables that all have these fields: id, code, name, description.
.NET2.0 enums do not easily support such a thing. So what i did was "faked" it using code much like the one below (which i created a CodeSmith template for). I am new to NHibernate and would like to know how i map such classes to their tables using NHibernate?
Code:
using System;
namespace LookUpTypes
{
/// <summary>
/// An enum representation of the 'StatusType' table. [No description found in the database]
/// </summary>
/// <remark>this struct is uses the items contained in the table StatusType</remark>
[Serializable]
public struct StatusType
{
public int Id; //should map to id field in StatusType table
public string Code; //should map to code field in StatusType table
public string Name; //should map to name field in StatusType table
public string Description; //should map to description field in StatusType table
private StatusType(int id, string code, string name, string descr)
{
this.Id = id;
this.Code = code;
this.Name = name;
this.Description = descr;
}
public static StatusType SUBMITTED = new StatusType(1000, "SUBMITTED", "Submitted", "WorkItem Submitted");
public static StatusType APPROVED = new StatusType(1010, "APPROVED", "Approved", "WorkItem Approved");
public static StatusType REJECTED = new StatusType(1020, "REJECTED", "Rejected", "WorkItem Rejected");
}
}