简体   繁体   English

OData v2按$扩展实体的属性过滤

[英]OData v2 filter by property of $expanded entity

I am using $expand to enhance an OData SharePoint REST query, and I would like to $filter on one of the properties of the expanded entity. 我使用$expand来增强OData SharePoint REST查询,我想对扩展实体的其中一个属性进行$filter However, I can't find any documentation on the correct syntax for this. 但是,我找不到任何关于正确语法的文档。 I've found a few spots that might suggest using Entity/property, but after trying that, I fail with: 我发现了一些可能建议使用Entity / property的地方,但在尝试之后,我失败了:

Query: 查询:

_vti_bin/listdata.svc/Posts?$expand=Category&$filter=substring(\"Featured Article\",Category/Title) eq false and year(Published) lt " +year+1+ " and month(Published) lt " +month+1+ " or day(Published) lt " +day+1+ " and ApprovalStatus eq '0'&$select=Title,Published,Category,ApprovalStatus&$orderby=Published desc"

Which returns: 哪个回报:

syntax error '\"' at position 10.

How would I filter based on the Title of the Category entity, when Category is a high level, and it's Title property is a sub-level? 当Category为高级别时,我将如何根据类别实体的标题进行过滤,并且它的Title属性是子级别?

The filter on navigation entities is independent of the expand. 导航实体上的过滤器与扩展无关。

It looks like the problem is the slash-escaped double quote and that you're using substring instead of substringof . 看起来问题是斜线转义双引号,而你使用的是substring而不是substringof

Does it work if you use single quotes instead? 如果你改用单引号,它会起作用吗? Or did you want to literally match the double-quote character? 或者你想要真正匹配双引号字符? (If that's the case, I think you can just leave the double quote unescaped inside the single quotes) (如果是这种情况,我认为你可以将双引号保留在单引号内)

_vti_bin/listdata.svc/Posts?$expand=Category&$filter=substringof('Featured Article',Category/Title) eq false

or 要么

_vti_bin/listdata.svc/Posts?$expand=Category&$filter=substringof('"Featured Article"',Category/Title) eq false

As an example on a public service, take a look at this query: 作为公共服务的示例,请查看此查询:

http://services.odata.org/Northwind/Northwind.svc/Products?$filter=substringof('Bev', Category/CategoryName) eq true

As far as documentation for the OData query syntax, I recommend taking a look at this page: http://www.odata.org/documentation/odata-v3-documentation/url-conventions 至于OData查询语法的文档,我建议看一下这个页面: http//www.odata.org/documentation/odata-v3-documentation/url-conventions

In the filter section there are a fair number of examples you can use for guidance. 在过滤器部分中,您可以使用相当多的示例作为指导。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM