Number Column mapping to nullable boolean Property gets casted wrong in certain expressions
Posted: Thu 08 Jun 2017 10:10
My table "TEST" has a NUMBER(1) property "ACTIVE". It is represented by a nullable boolean property "Active" in my EFCore model. The problem doesn't happen with non-nullable boolean properties.
When I select with a simple condition as follows, it works fine and produces the following correct SQL:
However, when I introduce a boolean && into the condition, the SQL is missing the crucial "= 1", resulting in a ORA-00920 exception.
When I select with a simple condition as follows, it works fine and produces the following correct SQL:
Code: Select all
var x = ctx.Test.Where(z => (bool)z.Active);
Console.WriteLine(x.Count());
Code: Select all
SELECT COUNT(*)
FROM TEST "z"
WHERE "z".ACTIVE = 1
Code: Select all
x = ctx.Test.Where(z => (bool)z.Active && (bool)z.Active);
Console.WriteLine(x.Count());
Code: Select all
SELECT COUNT(*)
FROM TEST "z"
WHERE "z".ACTIVE AND "z".ACTIVE