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

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
stoph
Posts: 8
Joined: Wed 25 Jun 2008 05:59

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

Post by stoph » Tue 25 Nov 2008 06:33

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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 25 Nov 2008 12:25

Thank you for the report. We have reproduced the error and now we are investigating it.

rick.duarte
Posts: 35
Joined: Fri 23 Jan 2009 23:07
Location: Rio de Janeiro, Brazil

Another Order By Error

Post by rick.duarte » Fri 23 Jan 2009 23:12

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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 26 Jan 2009 10:41

This problem is already fixed, look forward to the next build.

rick.duarte
Posts: 35
Joined: Fri 23 Jan 2009 23:07
Location: Rio de Janeiro, Brazil

Linq with descending order by - next version

Post by rick.duarte » Mon 26 Jan 2009 14:23

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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 27 Jan 2009 09:51

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.

Post Reply