I have a number of enums in my application which are used as property type in some classes.
What is the best way to store these values in database, as String or Int?
FYI, I will also be mapping these attribute types using fluent Nhibernate.
Sample code:
public enum ReportOutputFormat
{
DOCX,
PDF,
HTML
}
public enum ReportOutputMethod
{
Save,
Email,
SaveAndEmail
}
public class ReportRequest
{
public Int32 TemplateId
{
get { return templateId; }
set { templateId = value; }
}
public ReportOutputFormat OutputFormat
{
get { return outputFormat; }
set { outputFormat = value; }
}
public ReportOutputMethod OutputMethod
{
get { return outputMethod; }
set { outputMethod = value; }
}
}
The implementation is easy in both cases, and performance differences should be minor.
Therefore, go for the meaning : the Strings are more meaningful than numbers, so use the String.