This is a migrated thread and some comments may be shown as answers.
LINQ -> SQL bug? (Oracle)
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.
Top achievements
Rank 1
Matej asked on 07 Feb 2014, 11:02 AM

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.

1 Answer, 1 is accepted

Sort by
Viktor Zhivkov
Telerik team
answered on 12 Feb 2014, 09:54 AM
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.
LINQ (LINQ specific questions)
Asked by
Top achievements
Rank 1
Answers by
Viktor Zhivkov
Telerik team
Share this question