This is a migrated thread and some comments may be shown as answers.
.Single(x => x.id == id && ...) ignores extra conditions in generated SQL
1 Answer 6 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matej
Top achievements
Rank 1
Matej asked on 30 Jan 2015, 10:59 AM
Hello,

I think we've found a bug in Data Access Free Edition Q3 2014 SP1, that wasn't there before.

This example code:
var row = entities.Table.Single(x => x.id == id && x.Active);

Generates SQL of the form:
SELECT ...
FROM Table
WHERE id = <value>
thus ignoring the "Active" parameter.

Changing the code to:
var row = entities.Table.Where(x => x.Active).Single(x => x.id == id);
Produces the expected query (adds an "AND" clause checking Active).

Thanks,
Matej

1 Answer, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 30 Jan 2015, 02:19 PM
Hello Matej,

you are right, this is a glitch: when you use (x.Id == id && x.Active == true), the translation is correct. The failure comes from our internal GetObjectByKey detection that is is in place, but which fails to handle this non-compared boolean expression.

Thank you very much for reporting this issue, I've just fixed this and the next build will contain the needed bits.

Regards,
Thomas
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
LINQ (LINQ specific questions)
Asked by
Matej
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Share this question
or