I'm having an issue in Linq and have an object like this one:
{"Id": "",
"tDate": "2021-02-08T13:15:59.5419262Z",
"innerObject": [
{
"innerObjectId": "",
"tDate": "2021-02-08T13:15:59.528643Z"
}
],
...};
This is connected to an api, and when it's called I want to query this object and return all the attributes in ObjectDTO
while changing the tDate
in case there's a date in the innerObject
(I know that condition works, so no need to worry with that):
this.query = cosmosDbProvider.GetContainer().GetItemLinqQueryable<ObjectDTO>().AsQueryable()
.Where(t => someconditions)
.Select(o => { o.tDate = o.innerOject.Where(t => t.innerObjectId == input.innerObjectId).Select(t => t.tDate).ToArray()[0] ?? o.tDate;
return o; });
However, I can't seem to make this work. The errors I'm getting are 'A lambda expression with a statement body cannot be converted to an expression tree' and 'An expression tree may not contain an assignment operator'.
The other option I've tried is manually assigning each variable of ObjectDTO
, but that looks awful.
Does anyone have any ideas?