我有一个OData集合,其中的数据如下所示:
longjmp
我要排除具有“文件夹”属性的对象。我尝试使用GET请求:{
"@odata.context": "http://localhost:5488/odata/$metadata#folders",
"value": [
{
"name": "samples",
"_id": "79a91bc9-9083-4442-ac8d-ad30777ac8c8",
"creationDate": "2019-08-05T04:39:00.670Z",
"modificationDate": "2019-08-05T04:39:00.670Z",
"shortid": "18xQnNv"
},
{
"name": "Population",
"folder": {
"shortid": "18xQnNv"
},
"_id": "7406269b-669c-41ce-92f3-f540792df07e",
"creationDate": "2019-08-05T04:39:00.750Z",
"modificationDate": "2019-08-05T04:39:00.750Z",
"shortid": "0ppeLV"
},
{
"name": "Invoice",
"folder": {
"shortid": "18xQnNv"
},
"_id": "525aff6a-6b10-4ad6-93ce-e9c753e8ade0",
"creationDate": "2019-08-05T04:39:00.790Z",
"modificationDate": "2019-08-05T04:39:00.790Z",
"shortid": "G3i2B3"
},
{
"name": "Default",
"_id": "58daf5aa-1f13-4ff9-be1f-8cb11a812485",
"creationDate": "2019-08-07T22:56:45.160Z",
"modificationDate": "2019-08-07T22:56:45.160Z",
"shortid": "Sm8LpmP"
}
]
}
,但没有成功。甚至有可能吗,有没有办法像这样过滤我的请求?
答案 0 :(得分:0)
您也许可以使用the all lambda operator完成此操作。所有操作员都将对空集合始终返回true。因此,如果您确定一个条件,即实际上不存在任何文件夹属性,则结果 应该 只能过滤那些具有空属性的对象。
这只是一个理论。您需要进行测试,但是您的样本上可能看起来像这样。
http://localhost:5488/odata/folders?$filter=folder/all(f:f/shortid eq 'xxxxxx')
您没有提到要使用的OData版本,但是lambda表达式至少是V4和更高版本。可能更早,不确定。