I use Entity Framework 6 (EF6), and I want to map a table with a column of type int which only have values 0 or 1 to a property of type bool on my entity.
I would like to do so without the need for having two properties for the same column by having a property that is not mapped using the property that is mapped in its get'er and set'er like this.
public class MyEntity
{
...
[NotMapped]
public bool MyColumnAsBool
{
get { return MyColumnAsInt == 1; }
set { MyColumnAsInt = value ? 1 : 0; }
}
public int MyColumnAsInt { get; set; }
...
}
But what I can not seem to figure out is if this can be done with Attributes alone like in NHibernate? and if not, why? Why hasn't it been implemented?
Its a hassle to have two properties for the same thing when both of them need to be public.