The requested page is not available for the requested platform. You are viewing the content for Default platform.

Enumeration Properties in Entity Framework

The example below illustrates how to implement Enumeration Properties in an Entity Framework Code-First class.

public TextOnlyEnum TextOnlyEnumProperty { get; set; }
public TextAndImageEnum TextAndImageEnumProperty { get; set; }
// ...
public enum TextOnlyEnum { Minor, Moderate, Severe }
public enum TextAndImageEnum {
    [ImageName("State_Priority_Low")]
    Low,
    [ImageName("State_Priority_Normal")]
    Normal,
    [ImageName("State_Priority_High")]
    High 
}

To be able to use this enumeration type in design-time criteria editors, register it in the constructor of your ModuleBase descendant using the EnumProcessingHelper.RegisterEnum method as follows.

using DevExpress.Data.Filtering;
//...
public sealed partial class MySolutionModule : ModuleBase {
    public MySolutionModule() {
        InitializeComponent();
        EnumProcessingHelper.RegisterEnum(typeof(MySolution.Module.BusinessObjects.MyClass.TextOnlyEnum));
        //...
    }
    //...
}
See Also