odata - 结合 $expand 和 $select [英] odata - combining $expand and $select
问题描述
在 odata v4.0 中是否有将 $expand 和 $select 组合在一起的选项?
In odata v4.0 is there an option for combining $expand and $select together?
我有一个场景,我试图在其中获取特定的列productItemChoices 和 item.以下查询将为您提供所有productItemChoices 中的列.我只需要一列productItemChoices
I have a scenario wherein I'm trying to get specific columns in productItemChoices and item. The below query will give you all the columns in productItemChoices. I only need one column in the productItemChoices
odata/Products(08f80b45-68a9-4a9f-a516-556e69e6bd58)?$expand=productItemChoices($expand=item($select=name))
推荐答案
在这个问题上经过了很多时间,我终于得到了答案.我们可以使用 ;
作为分隔符将 select
嵌套在 expand
中,例如
After going through a lot of time on this, I finally got the answer. We can nest select
within expand
using ;
as a separator, something like
odata/Products(8)?$expand=choices($select=col1,col2;$expand=item($select=name))
这记录在 OData v4 $expand
文档.该文档还列出了其他有用的示例,例如
This is documented in the OData v4 $expand
documentation. The documentation also lists other useful examples such as
Categories?$expand=Products($filter=DiscontinuedDate eq null)
Categories?$expand=Products/$count($search=blue)
这篇关于odata - 结合 $expand 和 $select的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!