OrderByDescending followed by FirstOrDefault - does not work

OrderByDescending followed by FirstOrDefault - does not work

Postby pokaragat » Fri 03 Apr 2009 20:31

Here's the query:

var lastSuccessLoginDate = scopeManager.LOGIN_ATTEMPTS.Where(c => c.LOGIN_STATUS == 'SUCCESS').OrderByDescending(c => c.LOGIN_DATE_TIME).FirstOrDefault();

Here's DBMonitor sql trace:

SELECT
"Project1".C1 AS C1,
........(omitted for clarity)
FROM ( SELECT
.......(omitted for clarity)
1 AS C1
FROM VCL.LOGIN_ATTEMPTS "Extent1"
WHERE ("Extent1".LOGIN_STATUS = &p__linq__305)
) "Project1"
WHERE ROWNUM <= (1)
ORDER BY "Project1".LOGIN_DATE_TIME DESC



Note:
The ROWNUM <= (1) comes before ORDEY BY

I would expect it to be implemented as:

SELECT
"Project1".C1 AS C1,
........(omitted for clarity)
FROM ( SELECT
.......(omitted for clarity)
1 AS C1
FROM VCL.LOGIN_ATTEMPTS "Extent1"
WHERE ("Extent1".LOGIN_STATUS = &p__linq__305)
ORDER BY "Project1".LOGIN_DATE_TIME DESC
) "Project1"
WHERE ROWNUM <= (1)

::the Order by is in the subquery.
pokaragat
 
Posts: 23
Joined: Mon 15 Sep 2008 21:09

Postby AndreyR » Mon 06 Apr 2009 11:19

This problem is fixed in dotConnect for Oracle 5.20.24 Beta.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to dotConnect for Oracle