Bre*_*ans 5 odata asp.net-web-api2 odata-v4
我有一个为OData v4配置的web api 2.2.我希望按ID返回用户,并且仅包含用户所属的用户组ID.当我这样做
http://localhost/User?$filter=id eq 312&$select=*,userGroups/id&$expand=userGroups
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
URI中指定的查询无效.在select子句中找到具有多个导航属性的路径.请重新设置您的查询,以便每个级别的select或expand仅包含TypeSegments或Properties.
在select子句中找到具有多个导航属性的路径.请重新设置您的查询,以便每个级别的select或expand仅包含TypeSegments或Properties.
如果我删除",userGruops/id",查询将执行
你应该这样写你的查询:
http://localhost/User?$filter=id eq 312&$select=*&$expand=userGroups($select=id)
Run Code Online (Sandbox Code Playgroud)
顺便说一下,您还可以删除该$select=*段,因为默认情况下所有非导航属性都包含在响应中。