我正在将 WebAPI 2.2 与 OData V4 结合使用。
我可以使用 $filter=RelatedObj/PropertyName eq 'Some Value'
根据相关对象属性值过滤实体列表。
但是,当我尝试对 $select
使用相同的语法时:
$select=Id,Name,RelatedObj/PropertyName
结果异常:
"message": "The query specified in the URI is not valid. Found a path with multiple navigation properties or a bad complex property path in a select clause. Please reword your query such that each level of select or expand only contains either TypeSegments or Properties.",
"innererror": {
"message": "Found a path with multiple navigation properties or a bad complex property path in a select clause. Please reword your query such that each level of select or expand only contains either TypeSegments or Properties.",
"type": "Microsoft.OData.Core.ODataException",
这个问题能解决吗?
最佳答案
您可以使用 $expand
和嵌套 $select
查询选项来实现
$select=Id,Name&$expand=RelatedObj($select=PropertyName)
关于.net - 使用 OData $select 从相关对象中挑选字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30868614/