OData v2按$ expanded实体的属性过滤

Bri*_*sch 4 ajax rest sharepoint-2010 odata

$expand用来增强OData SharePoint REST查询,并且希望$filter扩展实体的属性之一。但是,我找不到关于正确语法的任何文档。我发现了一些建议使用实体/属性的地方,但是尝试之后,我失败了:

查询:

_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"
Run Code Online (Sandbox Code Playgroud)

哪个返回:

syntax error '\"' at position 10.
Run Code Online (Sandbox Code Playgroud)

当Category为高级别且Title属性为子级别时,如何根据Category实体的Title进行过滤?

i00*_*174 7

导航实体上的过滤器与扩展无关。


Jen*_*n S 2

看起来问题是斜杠转义的双引号,并且您正在使用而substring不是substringof.

如果使用单引号代替,它会起作用吗?或者您想字面匹配双引号字符吗?(如果是这种情况,我认为您可以将双引号保留在单引号内)

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

或者

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

作为公共服务的示例,请看一下以下查询:

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

至于 OData 查询语法的文档,我建议查看此页面:http ://www.odata.org/documentation/odata-v3-documentation/url-conventions

在过滤器部分中,有大量示例可以用作指导。