Actually, this appears to work, but doesn't scale beyond a few thousand documents.
var ordered = result.OrderByDescending(x => x.ProductId == 3000);
for (int i = 2999; i >= 0; i--)
{
int closureCopy = i;
ordered = ordered.ThenByDescending(x => x.ProductId == closureCopy);
}
var res =
ordered.ToList();
The scenario is this:
I get a result from an external system, this result contains document Ids for RavenDB and live pricing information which cannot be stored in ravendb. What I want to do then is to fetch these ids in a particular order, determined by the pricing. I will also do paging on the result, which is why I cannot sort it after fetching it from RavenDB.
I've pondered taking apart the result from the external service and doing the paging myself before fetching the result from RavenDB, but I was hoping for a cleaner solution using the db. Do you see any possible solutions?