Replies: 1 comment
-
I'm not sure if it's possible to order by an element in a nested collection where that element matches a given condition in OData. How would this be represented in LINQ? I think the best approach would be to move the property that would be ordered out of the collection. You said there is not reasonable way to flatten the data structure. Could you shed more light on this? Would it be possible to add copy of |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I have a similar case:
code example
I want to get the Items ordered by the PropertyZ value of the NestedItems collection using only a specific 'Type' - that always returns a single element from the nested collection.
For example, the response could be
The results are ordered by NestedItems(type="TypeA")/PropertyZ in ascending order.
Below example queries that I have tried:
http://{URL_API}/items/?$expand=nesteditems&$orderby=nesteditems($top=1;$filter=type eq 'TypeA')/propertyz
http://{URL_API}/items/?$expand=nesteditems&$orderby=nesteditems/any(item: item/type eq 'TypeA')/propertyz
Currently, I can sort by PropertyX or Id, but I cannot sort the results by NestedItems.PropertyZ nor NestedItems.Id.
There is no reasonable way to flatten the data structures. Do I have some other alternatives to apply?
I appreciate your help!
Beta Was this translation helpful? Give feedback.
All reactions