Best way to store enum values in database - String or Int

Posted by inutan on Stack Overflow See other posts from Stack Overflow or by inutan
Published on 2009-10-23T09:25:57Z Indexed on 2010/03/25 9:03 UTC
Read the original article Hit count: 341

Filed under:
|
|
|

Hello there,

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; }
    }
}

© Stack Overflow or respective owner

Related posts about enum

Related posts about database