.Single(x => x.id == id && ...) ignores extra conditions in generated SQL

2 posts, 0 answers
  1. Matej
    Matej avatar
    5 posts
    Member since:
    Sep 2012

    Posted 30 Jan 2015 Link to this post


    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).

  2. Thomas
    Thomas avatar
    588 posts

    Posted 30 Jan 2015 Link to this post

    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.

    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
  3. DevCraft banner
Back to Top