odata - 结合$ expand和$ select

pra*_*nag 22 expand select asp.net-web-api odata-v4

在odata v4.0中是否有将$ expand和$ select组合在一起的选项?

我有一个场景,我正在尝试获取productItemChoices和item中的特定列.以下查询将为您提供productItemChoices中的所有列.我只需要productItemChoices中的一列

odata/Products(08f80b45-68a9-4a9f-a516-556e69e6bd58)?$expand=productItemChoices($expand=item($select=name))
Run Code Online (Sandbox Code Playgroud)

pra*_*nag 42

经过这么多时间后,我终于得到了答案.我们可以selectexpand使用中;作为分隔符嵌套,例如

odata/Products(8)?$expand=choices($select=col1,col2;$expand=item($select=name))
Run Code Online (Sandbox Code Playgroud)

这在OData v4 $expand文档中有记录.该文档还列出了其他有用的示例,例如

Categories?$expand=Products($filter=DiscontinuedDate eq null)
Categories?$expand=Products/$count($search=blue)
Run Code Online (Sandbox Code Playgroud)