Only last Order clause used
Posted: Wed 20 Jun 2012 08:54
Hi everyone,
I have been using Linq-to-SQL for quite a while and now switched to dotConnect for Oracle using Entity Framework 4. I have several queries, where the user can select the field to sort on. I also apply a default sorting on several other columns. With Linq-to-SQL I was able to do something like this:
This would result in the last Order clause being the first to sort by, and the default sort being applied afterwards, i.e. "ORDER BY ColC, ColA, ColB". With dotConnect for Oracle, however, only the last OrderBy seems to be taken into account. When I use the ObjectQuery.ToTraceString method, I only get ORDER BY ColC or something similar. ColA and ColB are simply ignored.
I know, the simple workaround is to simply add the default sorting to all the sort operations, but this results in much less maintainable code and a bunch of redundancy. So, I was wondering, whether this might be a bug, that might be fixed in the near future.
Thanks,
Christoph
I have been using Linq-to-SQL for quite a while and now switched to dotConnect for Oracle using Entity Framework 4. I have several queries, where the user can select the field to sort on. I also apply a default sorting on several other columns. With Linq-to-SQL I was able to do something like this:
Code: Select all
// apply default sort
query = query.OrderBy(it => it.ColA).ThenBy(it => it.ColB);
switch (sortKey) {
case "ColC": query = query.OrderBy(it => it.ColC); break;
case "ColD": query = query.OrderBy(it => it.ColD); break;
}
I know, the simple workaround is to simply add the default sorting to all the sort operations, but this results in much less maintainable code and a bunch of redundancy. So, I was wondering, whether this might be a bug, that might be fixed in the near future.
Thanks,
Christoph