user152949
user152949

Reputation:

Does TableQuery support OrderBy?

I can't figure out how to add a OrderBy clause to a TableQuery with Azure Table Storage.

According to their documentation Azure supports OData $orderby. If I try to hack it by adding $orderby=PartitionKey to the TableQuery Where clause the '$' is HTTP-encoded and I get a 400 server error because of it - so hacking it in wont work. Here is what my hack produces:

GET /devstoreaccount1/NewTable3?$filter=PartitionKey%20ne%20%27pkey992%27%24orderby%3DName&$select=Name%2Cregistered%2CPartitionKey%2CRowKey%2CTimestamp HTTP/1.1

Does TableQuery support OrderBy, and if yes then how?

Upvotes: 15

Views: 17360

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136366

Does TableQuery support OrderBy, and if yes then how?

No. As of today, Table Service does not support Order By. Please see the list of supported LINQ Operators here.

What you would need to do is fetch the data (which will be sorted by PartitionKey and RowKey) and apply the sorting on the client side.

Upvotes: 25

Related Questions