With Entity Framework from SQL I am accessing a field that its schema says "bit"
Now I want to put it in C# code in an int
I wrote something like this: Is this correct? or there are other ways?
int myResult = Convert.ToInt32(ef.thatField);
maybe you can try this :
int myResult = ef.thatField ? 1 : 0;
bit can be mapped to bool? instead of bool. In this case you can caught the runtime exception.NULL maps to. After all, he isn't trying to cast it to int?.
intinstead of abool?Convert.ToInt32(someBoolean);should work fine.bitcan be mapped tobool?instead ofbool.