LINQ -> SQL bug? (Oracle)

Thread is closed for posting
2 posts, 0 answers
  1. Matej
    Matej avatar
    5 posts
    Member since:
    Sep 2012

    Posted 07 Feb 2014 Link to this post


    I've tried running a query in the form
    stuff.Where(s => maxDate > (s.IdNav1.HasValue
        ? s.Nav1.Date
        : (s.IdNav2.HasValue
            ? s.Nav2.Date
            : s.Date)));
    But the generated query was composed of inner joins on Nav1 and Nav2, and consequently returned too few results.

    This worked:
    stuff.Where(s => s.IdNav1.HasValue && s.Nav1.Date < maxDate
        || !s.IdNav1.HasValue && s.IdNav2.HasValue && s.Nav2.Date < maxDate
        || !s.IdNav1.HasValue && !s.IdNav2.HasValue && s.Date < maxDate);
    (This generates "exists" clauses, no joins.)

    Am I doing something incorrectly or is this a bug?

    Thank you,

    The Telerik version we're using is 2013.3.1211.3.
  2. Viktor Zhivkov
    Viktor Zhivkov avatar
    324 posts

    Posted 12 Feb 2014 Link to this post

    Hi Matej,

    The second version of the query is the right one to use in your scenario.
    The first one is a bit hard to translate to the SQL statement that you are expecting in general scenarios and as you already experienced Data Access is handling is using INNER JOIN.

    If you have similar relatively complex queries its a good idea to check if the SQL is the expected one and the results match the ones you have in mind.

    If you need any other questions do not hesitate to contact us.

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