.net – 使用OData $select来从相关对象中挑选字段

我正在使用带有OData V4的WebAPI 2.2.

我可以使用$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)

ODATA documentation

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....