Paging and OrderBy problem

259 views
Skip to first unread message

Phil Jones

unread,
Sep 12, 2011, 12:02:47 PM9/12/11
to Simple.Data
Hello,

Getting the following error trying to define a sorting on my paging
query:

Column "dbo.Proposal.ID_Proposal" is invalid in the ORDER BY clause
because it is not contained in either an aggregate function or the
GROUP BY clause.

Seems pretty simple if I were writing the SQL but how do you make
Simple.Data apply the order by in the correct place?

Code:

public dynamic GetProposals(out int pageCount, int page = 1)
{
int recordsToSkip = 0;

if (page > 1)
recordsToSkip = (page - 1) * 30;

Future<int> count;

var q = _database.Proposal.Query()
.Join(_database.Customer_User).On(_database.Proposal.ID_User
== _database.Customer_User.ID_User)
.Join(_database.Trip).On(_database.Proposal.ID_Trip
== _database.Trip.ID_Trip)
.Select(
_database.Proposal.ID_Proposal
, _database.Trip.Trip_Name
, _database.Proposal.Departure_Date
, _database.Proposal.Send_Status
, _database.Customer_User.Name)
.OrderByDescending(_database.Proposal.ID_Proposal)
.WithTotalCount(out count)
.Skip(recordsToSkip)
.Take(30)
.ToList();

pageCount = count.Value;
return q;
}

Mark Rendle

unread,
Sep 13, 2011, 12:11:34 AM9/13/11
to simpl...@googlegroups.com
Do I take it from Twitter that you made this work?

Sent from my iPad

Phil Jones

unread,
Sep 13, 2011, 12:45:27 AM9/13/11
to Simple.Data
Hi Mark,

No, this problem still exists.

Phil

P.s. Twitter problem was to do with UDF not paging which I solved by
adding a field to the table.

On Sep 13, 5:11 am, Mark Rendle <m...@markrendle.net> wrote:
> Do I take it from Twitter that you made this work?
>
> Sent from my iPad
>

Mark

unread,
Sep 29, 2011, 9:54:13 AM9/29/11
to Simple.Data
OK, reproduced, working on a fix now.

Mark

unread,
Sep 29, 2011, 10:36:17 AM9/29/11
to Simple.Data
Fixed. It wasn't removing the ORDER BY from the Query before
generating the SELECT COUNT(*) statement.

0.9.6.2, on NuGet now.

Cheers,
Mark

On Sep 13, 5:45 am, Phil Jones <phil.jone...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages