I am using Entity Framework 5 code first
. My table has a column called Active
and its datatype is of type int
. The values that are st
I tried the following because I do not know if Entity Framework can handle the conversion for me.
I removed this line:
this.Property(x => x.IsActive).HasColumnName("Active").HasColumnType("int");
I then added a property to my CommandExecutionServer class
:
public class CommandExecutionServer : IEntity
{
public int Id { get; set; }
public int? Active { get; set; }
public bool IsActive
{
get
{
return (Active == 1) ? true : false;
}
}
}
There might be a better way but this works for me for now. If any one can better this then please go ahead :)
SELECT CONVERT(A.bitcolumn as bit) as bitout
ado.net will convert bits to bools. So, just convert your integer to a bit in your select statement in t-sql.