New Posts New Posts RSS Feed: Error when using SubQuery and OrderBy
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Error when using SubQuery and OrderBy

 Post Reply Post Reply
Author
johneevo View Drop Down
Newbie
Newbie


Joined: 03-Dec-2007
Location: United States
Posts: 8
Post Options Post Options   Quote johneevo Quote  Post ReplyReply Direct Link To This Post Topic: Error when using SubQuery and OrderBy
    Posted: 10-Dec-2007 at 6:49am
I'm receiving a "Failed to compare two elements in the array." error when using a query that has a subquery and order by clauses. I am ordering by 5 columns but the one that is causing the problem is an int32 column that contains NULLs.

If I suppress query inversion I do not get an error but the data is not sorted correctly.

If I leave query inversion on and do not sort by the problem column, then I do not get an error and the data is sorted correctly.

The inner exception that I get with the above mentioned query is:
"At least one object must implement IComparable."

Let me know if you need more info on this error.
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 10-Dec-2007 at 8:56am
This appears to be a .NET problem, not a DevForce problem.  If you search the web, you can find a few links to articles which discuss this problem.
 
Try:
 
 
 
 
Perhaps, one of your Entities needs to override IComparable (as shown in the example below):
 
 public override int CompareTo(Object pObject) {
   Employee emp = pObject as Employee;
   if (emp == null) return 1;
   return this.LastName.CompareTo(emp.LastName);
  }
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down