Problem with SQL WHERE clause generated for boolean

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
rstefan
Posts: 6
Joined: Mon 31 Aug 2009 15:11

Problem with SQL WHERE clause generated for boolean

Post by rstefan » Wed 26 May 2010 08:33

I have columns in my database as NUMBER(1) which are mapped in my entities to boolean (build with entity developer).
Fine for me.
In database, false values are 0, and true values are different from 0 (often -1).

When I checked the boolean properties of the entities, the property is true if the value in database is different from 0. Fine again.

But when I try to write a Linq expression with a boolean property it fails to return the good result.
For example : a query retrieves all diagnosis that are not obsolete.

Code: Select all

var query = from d in myRepository.Diags where !d.Obsolete;
Here a part of the SQL generated (read from dbMonitor) :

Code: Select all

SELECT ...
FROM DIAGS "Extent1"
	WHERE "Extent1".FOBSOLETE  1
The problem is that where clause can't get the records with true value coded with -1. And it's different for the property value itself.
I use a workaround by testing d.Obsolete != false but it's a bit obvious and the risk of errors in the entire code is major.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 28 May 2010 09:39

Thank you for the report. We will investigate the possibility to implement your suggestion.
I will let you know about the results.

Post Reply