I am trying to map tinyint column to byte property in c#How to achieve this efficiently. I want to store the values null, 0 and 1 to the database column. Please find below my code. Can anyone help me whether the following is the right approach?
public enum TriState : byte
{
Null = 0,
True = 1,
False =2
}
[NotMapped]
public TriState AuthorisationStatus { get; set; }
[Column("AuthorisationStatus")]
public byte AuthorisationStatusByte {
get
{
return Convert.ToByte(AuthorisationStatus.ToString());
}
private set
{
AuthorisationStatus = EnumExtensions.ParseEnum<TriState>(value);
}
}
public static T ParseEnum<T>(byte value)
{
return (T)Enum.Parse(typeof(T), value.ToString(), true);
}
Thanks