How to map int in enum to EF

Anyway to map an int field to enum in EFv1? Thank you I want my entity to have an enumeration field, not an int field.

+5
source share
3 answers

Create two properties. One is displayed in EF, one as a wrapper

[EdmScalarProperty]
public int EnumPropInteger {get;set}
public MyEnum EnumProp
{
    get { return (MyEnum) EnumPropInteger; }
    set { EnumPropInteger = (int)value; }
}

Not a good way, because you have two public properties, but a way.

+6
source

int Enum :

public enum TestEnum
{
Zero = 0,
One,
Two
}

TestEnum target = (TestEnum)1;

TestEnum.One;

: , . , , ? , , .

-2

All Articles