EnumStorageType property

Indicates how enumeration properties / fields should be persisted to the database.

Namespace: ReFlex.Data namespace
Assembly: ReFlex.Data.dll

Syntax

public Type EnumStorageType = typeof(int);

Remarks

Sometimes developers may wish to store an enumeration property or field in the database as a string. By setting this attribute as typeof(string), ObjectFactory will persist the enumeration as the string representation.

Default storage type is int.

Examples

// communication preference will be persisted to the database as either 'Mail', 'Phone' or 'Email'
public class Contact
{
    public enum CommunicationPreferenceEnum
    {
        Mail = 1,
        Phone = 2,
        Email = 3
    }
   
    public int ContactID;

    [RelationalMemberInfo(Length = 50)]
    public string FirstName;

    [RelationalMemberInfo(Length = 50)]
    public string LastName;

    [RelationalMemberInfo(EnumStorageType = typeof(string)]
    public CommunicationPreferenceEnum CommunicationPreference = CommunicationPreferenceEnum.Email;
}