ORDER BY

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Zoran
Posts: 44
Joined: Thu 28 Apr 2005 21:55
Location: Zagreb, Croatia

ORDER BY

Post by Zoran » Tue 01 Sep 2009 00:40

1. Order by a column that is not a PK (DocumentNumber):

(from q in SalesOrders
where q.Id == 1
select q).OrderBy(x => x.DocumentNumber)

generates an error ("Specified method is not supported.").

2. The same code ordered by a PK (Id) generates no error:

(from q in SalesOrders
where q.Id == 1
select q).OrderBy(x => x.Id)

3. The result is the same when using from...where...orderby...select query.

4. (from q in SalesOrders
where q.Id == 1
select q).AsEnumerable().OrderBy(x => x.DocumentNumber)
always works.

How can I use remote ORDER BY? Ordering by a not-PK column worked fine up to a few versions ago.

Shalex
Devart Team
Posts: 8032
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 04 Sep 2009 10:19

Please try the 4.55.39 version of dotConnect for PostgreSQL. Does the problem persist with this version too? If yes, please post here your call stack when the error arises with the 4.55.39 version. We cannot reproduce the issue.

Zoran
Posts: 44
Joined: Thu 28 Apr 2005 21:55
Location: Zagreb, Croatia

Post by Zoran » Sat 05 Sep 2009 07:25

I used 4.55.39. Here is the stack:
at Devart.Data.Linq.Provider.Query.p.c.a(a0 A_0, MemberInfo A_1)
at Devart.Data.Linq.Provider.Query.p.c.b(bc A_0)
at Devart.Data.Linq.Provider.Query.p.c.a(bc A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.a(SqlNode A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.c(SqlExpression A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.a(o A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.a(SqlNode A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.c(SqlExpression A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.e(bo A_0)
at Devart.Data.Linq.Provider.Query.p.c.a(bo A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.a(ax A_0)
at Devart.Data.Linq.Provider.Query.p.c.a(ax A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.a(SqlNode A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.e(SqlNode A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.e(bo A_0)
at Devart.Data.Linq.Provider.Query.p.c.a(bo A_0)
at Devart.Data
.Linq.Provider.Query.SqlVisitor.a(ax A_0)
at Devart.Data.Linq.Provider.Query.p.c.a(ax A_0)
at Devart.Data.Linq.Provider.Query.SqlVisitor.a(SqlNode A_0)
at Devart.Data.Linq.Provider.Query.p.a(SqlNode A_0, SqlFactory A_1, TypeSystemProvider A_2, ao A_3, a A_4)
at Devart.Data.Linq.Provider.DataProvider.a(c A_0, Type A_1, SqlNode A_2, IList`1 A_3)
at Devart.Data.Linq.Provider.DataProvider.a(Expression A_0)
at Devart.Data.Linq.Provider.DataProvider.h(Expression A_0)
at Devart.Data.Linq.DataQuery`1.i()
at Microline.Test.Test.test46() in C:\Users\Administrator\Source\C#\MOL\Test\Test.cs:line 1130
at Microline.Test.Test.render() in C:\Users\Administrator\Source\C#\MOL\Test\Test.cs:line 1110

Shalex
Devart Team
Posts: 8032
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 07 Sep 2009 15:06

Please check the DocumentNumber property. Probably, it is not mapped to the field of the table via the Column's attributes.

Zoran
Posts: 44
Joined: Thu 28 Apr 2005 21:55
Location: Zagreb, Croatia

Post by Zoran » Tue 08 Sep 2009 00:38

This was a bad example because DocumentNumber overrides OrderNumber, but order by OrderNumber doesn't work either although it is defined with an attribute: [Column (Storage = "orderDate", Name = "Orddate")]. I assume that the definition is all right because other operations work with columns that cannot be a part of "order by" clause. Or is there an error here?
Error stack for OrderNumber seems to be the same as for DocumentNumber.

Shalex
Devart Team
Posts: 8032
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 09 Sep 2009 12:38

Could you please send us a working sample with DataContext (or part of DataContext which participates in the query)? We will try to reproduce the problem. Please contact us via our contact form (http://www.devart.com/company/contact.html).

Zoran
Posts: 44
Joined: Thu 28 Apr 2005 21:55
Location: Zagreb, Croatia

Post by Zoran » Sat 12 Sep 2009 19:03

I am hesitating because it will take some tome to make the separate project. Because of performance I decided not to use LINQ in complex queries and in simple ones AsEnumerable() solves the problem.

Post Reply