I have a database column ‘WantsReply’ that logically holds a boolean (bit) but is unfortunately implemented as an integer. Any nonzero value means ‘yes’ and zero means ‘no’.
If I write
class Entry { [Column] public int WantsReply {get; set;} }
in my model, and map it to a checkbox in the view using
Html.CheckBox( 'WantsReply', View.Model.WantsReply )
then I get a conversion error when I submit the view. On the other hand if I write
[Column] public bool WantsReply {get; set;}
then the view submit works OK but then I get a different conversion error when I run a query like
from entry in Entries select entry;
How can I resolve this impedance mismatch so that both queries and submits work?
Instead of changing the type of the column property, why not map it to a new property?
The integer property can be private, if you like. Use the bool property in your view.