I'm trying to use the predicate builder to get the LastVerifiedDate ordered in descending order by using the PredicateBuilder in LinqKit So far It didn't work out. Here's what I have tried so far:
var predicate = PredicateBuilder.New<Item>();
predicate.And(f => OrderByDescending(f.LastVerfiedDate)); // Not working code
Im okay to add to Cosmos Query aswell like below:
var response = _client.CreateDocumentQuery<T>(_tools.GetCollectionUri<T>(),
new FeedOptions
{
PartitionKey = new PartitionKey(partitionKey), MaxItemCount = requestCommand.PageSize,
RequestContinuation = requestCommand.Token
})
var docQuery = response.Where(predicate).OrderByDescending(f.LastVerfiedDate); // OrderByDescending not available
Question:
Can this be achievable using CreateDocumentQuery?
Basically I need to fetch data in descending order based on LastVerifiedDate attribute. If so can someone provide code sample which I can try out?
I was basically able to achieve ordering data based on Expression via the below code. Posting it here for anyones reference.
My use case was to order the data based on
DateTimeparameter calledLastVerifiedDatewhich I have from data fetched CreateDocumentQuery. I was able to achieve like below :Invoking the above method like below :