Linq to SQL Boolean operation convertion

5 03 2009

Another limit when using Linq To SQL is the SQL translation of boolean operation.
For exemple, when writting:

from s in sTable
select new{
BoolValue=BoolValue1&&BoolValue2
}

the corresponding SQL interpretation will be like that:

select BoolValue=case when (BoolValue1 and BoolValue2) then 1
when !(BoolValue1 and BoolValue2) then 0
else NULL end
from sTable

However, the wished result is 1 or 0, not NULL .
Be aware of that when processing boolean operation…


Actions

Information

Leave a comment