If you want to store the data in the database then I dont think you will have any other choice than to go with approach 2 but use it as a value object which mnichols describes. Or I guess you could have a many to one assosciation and just cache the objects since the data will most likely never change, but then you have to have a full blown entity.
Another alternative if you can get by without storing the data in the database is to use predefined or custom attributes on your enum values. For example you could use System.ComponentModel.DescriptionAttribute to do something like this:
Code:
public enum Color
{
[Description("Cool Red")]
Red,
[Description("Awesome Yellow")]
Yellow,
[Description("Groovy Green")]
Green
}
You would need a wrapper or helper class that could read the attributes. If you use a wrapper you copuld have your entity return a reference to the wrapper as opposed to the enum.
Code:
public class ColorWrapper{
Color _value;
string _description;
public ColorWrapper(Color value){
this._value = value;
}
public Color Value{
get{return this._value;}
}
public string Description{
get{
if(this._description == null){
FieldInfo fi= typeof(Color).GetField(this._value.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute), false);
this._desciption = (attributes.Length>0)?attributes[0].Description:string.Empty
}
return this._description;
}
}
}
You could add as many attributes as you need. Just a thought.