To add/expound on my recent question
Below are DocumentDB collections: "delivery"
{
"doc": [
{
"docid": "15",
"deliverynum": "123",
"text": "txxxxxx",
"date": "2019-07-18T12:37:58Z"
},
{
"docid": "17",
"deliverynum": "999",
"text": "txxxxxx",
"date": "2018-07-18T12:37:58Z"
}
],
"id": "123",
"cancelled": false
},
{
"doc": [
{
"docid": "16",
"deliverynum": "222",
"text": "txxxxxx",
"date": "2019-07-18T12:37:58Z"
},
{
"docid": "17",
"deliverynum": "999",
"text": "txxxxxx",
"date": "2019-07-20T12:37:58Z"
}
],
"id": "124",
"cancelled": false
}
I need to search the deliverynum=999 w/ the latest date to get the "id", which in the case above is "124" because it has the latest "date" in the "doc" w/ deliverynum=999.
I was going to do:
var list = await collection.Find(filter).Project(projection).ToListAsync();
then do a LINQ to sort, but the problem here is my projection change the list from my Model Class to BsonDocument even if my projection included all the fields.
Was looking for a way to either get just needed "id" or get the single document.