加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

在Web API 2.2上使用带有Odata v4.0的$select和$expand时出错

发布时间:2020-12-14 23:25:33 所属栏目:资源 来源:网络整理
导读:我有一个为OData v4配置的web api 2.2.我希望按ID返回用户,并且仅包含用户所属的用户组ID.当我这样做 http://localhost/User?$filter=id eq 312$select=*,userGroups/id$expand=userGroups 我收到这个错误 The query specified in the URI is not valid. Fou
我有一个为OData v4配置的web api 2.2.我希望按ID返回用户,并且仅包含用户所属的用户组ID.当我这样做
http://localhost/User?$filter=id eq 312&$select=*,userGroups/id&$expand=userGroups

我收到这个错误

The query specified in the URI is not valid. Found a path with
multiple navigation properties in a select clause. Please reword your
query such that each level of select or expand only contains either
TypeSegments or Properties.

Found a path with multiple navigation properties in a select clause.
Please reword your query such that each level of select or expand only
contains either TypeSegments or Properties.

如果我删除“,userGruops / id”,查询将执行

解决方法

您应该像这样编写查询:
http://localhost/User?$filter=id eq 312&$select=*&$expand=userGroups($select=id)

顺便说一句,您还可以删除$select = *段,因为默认情况下,所有非导航属性都包含在响应中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读