What is the best method of storing an Enum in a Database using C# And Visual Studio and MySQL Data Connector.
I am going to be creating a new project with over 100 E
If you need store in DB string values of enum field, better do like show below. For example, it can be needed if you are using SQLite, which don`t support enum fields.
[Required]
public string PhoneTypeAsString
{
get
{
return this.PhoneType.ToString();
}
set
{
PhoneType = (PhoneTypes)Enum.Parse( typeof(PhoneTypes), value, true);
}
}
public PhoneTypes PhoneType{get; set;};
public enum PhoneTypes
{
Mobile = 0,
Home = 1,
Work = 2,
Fax = 3,
Other = 4
}