1 year ago

#373018

test-img

RoryF

Sorting on a potentially Null value from Cosmos

I am looking to do sorting on Last updated date on a table that contains all of my user requests but the issue is this property was only recently added to the request model as it was previously pulled from logs, with older requests not having this defined until an update is made to the request.

The results are paginated and in the currently implementation will have blank entries were the undefined requests would be (nothing returned from DB call because of the OrderBy). This query is ran on each page load:

query = query.OrderBy(sort).Skip(offset).Take(pageLimit);

I am looking for my OrderBy query to my CosmosDb to have the requests ordered by last updated and the undefined requests to still show up at the end and sorted by a secondary sort, likely surname.

I am looking to keep it as one query and I have tried things such as OrderBy(sort.IsDefined()).ThenBy(sort) but I don't think these are supported? (or i couldn't seem to get these working anyways).

c#

azure

azure-cosmosdb

azure-cosmosdb-sqlapi

0 Answers

Your Answer

Accepted video resources