.net – 使用OData $select来从相关对象中挑选字段
发布时间:2020-12-16 06:39:16 所属栏目:asp.Net 来源:网络整理
导读:我正在使用带有OData V4的WebAPI 2.2. 我可以使用$filter = RelatedObj / PropertyName eq’Some Value’来根据相关的对象属性值过滤实体列表. 但是,当我尝试使用与$select相同的语法时: $select=Id,Name,RelatedObj/PropertyName 结果例外: "message": "T
我正在使用带有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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 获取当前请求的凭据以便在WebRequest中使用
- asp.net-mvc – 在mvc 5和web api 2之间共享owin cookie身份
- asp.net-mvc – MVC4 Razor – @ Html.DisplayFor没有绑定到
- asp.net – 处理包含页面的用户控制事件
- asp.net-mvc – ASP.Net MVC:如何根据原始的Json数据创建一
- ASP.NET C#中的自定义控件
- asp.net-mvc – 未找到或构造错误的路由
- razor-pages – 何时使用LocalRedirect与RedirectToPage
- .NET Core RC2发布在即,我们试着用记事本编写一个ASP.NET
- asp.net core 自定义 Policy 替换 AllowAnonymous 的行为