Page 1 of 1

ErrorLINQ: Table "order-by" with Descending and Table.First

Posted: Tue 25 Nov 2008 06:33
by stoph
I have the following Linq-query (example):

Code: Select all

dim result = from p in db.table _
    where p.field1 = 'value' _
    order by p.field2 Descending, p.field3 Descending
When i access the result with:

Code: Select all

dim field = result.First.field1
the wrong result row is returned. "field" contains the last row without the "Desc"-Sort.

I watched the generated SQL-Statement in DBMonitor. Linq sends the following SQL to the Database:

Code: Select all

SELECT t1.field1, t1.field2, t1.field3
FROM (
    SELECT t1.field1, t1.field2, t1.field3, ROW_NUMBER() OVER (ORDER BY t2.field2, t2.field3) AS rnum
    FROM table t2
    WHERE (t2.field1 = 'value') 
    ORDER BY t2.field2 DESC, t2.field3 DESC
    ) t1
WHERE t1.rnum <= 1
The correct statement should be:

Code: Select all

SELECT t1.field1, t1.field2, t1.field3
FROM (
    SELECT t1.field1, t1.field2, t1.field3, ROW_NUMBER() OVER (ORDER BY t2.field2 DESC, t2.field3 DESC) AS rnum
    FROM table t2
    WHERE (t2.field1 = 'value') 
    ORDER BY t2.field2 DESC, t2.field3 DESC
    ) t1
WHERE t1.rnum <= 1

Posted: Tue 25 Nov 2008 12:25
by AndreyR
Thank you for the report. We have reproduced the error and now we are investigating it.

Another Order By Error

Posted: Fri 23 Jan 2009 23:12
by rick.duarte
AndreyR,

I'm getting this error when descending order with LinqDataSource:
"ORA-00904: \"T2\".\"DO_TX_CONS_CPUDESC\": invalid identifier"

The correct should be:
"T2"."DO_TX_CONS_CPU" DESC

Do you have a solution for that?
I need to deploy my application.

Thanks,

Henrique

Posted: Mon 26 Jan 2009 10:41
by AndreyR
This problem is already fixed, look forward to the next build.

Linq with descending order by - next version

Posted: Mon 26 Jan 2009 14:23
by rick.duarte
AndreyR wrote:This problem is already fixed, look forward to the next build.
When will be available the next build?
Can you provide this build?
Do I need to contact the support for that?

Thanks,

Henrique

Posted: Tue 27 Jan 2009 09:51
by AndreyR
The build is planned to be released in two weeks.
I can't provide you this build, it will become available in Registered Users' Area.
There is no need to contact support for this, follow the announcements in the forum.