I have a view that is mapped onto an entity.
It has a nullable bit field in MS SQL. That translates to a bool field in .net.
When I do a query like the following, the bad SQL is generated:
var query = (from someTable in metadata.SomeTable
join theView in metadata.ViewInQuestion on someTable.SomeTablePkey equals theView.SomeTablePkey
select new
{
SomeBool = theView.SomeBool ?? false,
someTable.SomeTablePkey
});
If I change the query to this, it works:
var query = (from someTable in metadata.SomeTable
join theView in metadata.ViewInQuestion on someTable.SomeTablePkey equals theView.SomeTablePkey
select new
{
SomeBool = theView.SomeBool == null ? false : theView.SomeBool.Value,
someTable.SomeTablePkey
});
In the failure code, the SQL case statement that is generated fails to compare the bit to a 1/0.
We recently upgraded our LLBLGen library so I am not entirely sure what version this was against as it was a week or two ago when I found the bug and am just not getting around to reporting it. I think it was SqlServer 4.2.20151009, OrmSupport 4.2.20150210. Self servicing. Should be a pretty easy repo. (I didn't spend a ton of time researching - may not be related to the view, join, etc. As you see, I found a quick and easy workaround and moved along...but thought I would report it for next time. )