[英]How to write an OData call to get all entities with a specific property equal to an empty array
I have an api that uses REST/OData. 我有一个使用REST / OData的api。 All of the products have an expandable property that is an array of objects.
所有产品都具有作为对象数组的可扩展属性。 But some of the products are missing these objects.
但是某些产品缺少这些对象。 I need to find which ones by filtering out all the ones that have content in the arrays, and returning all of the ones that have an empty array.
我需要通过过滤掉数组中所有具有内容的内容并返回所有包含空数组的内容来找到哪些内容。
Here's the structure of a normal object: 这是普通对象的结构:
{
"odata.metadata": "https://myapi.com/$metadata#Products",
"value": [
{
"Name": "myName"
"StatusId": 1,
"Id": 88,
"DateCreated": "2015-01-22T14:30:00.6611598",
"DateModified": "2015-01-22T23:48:41.4590534",
"ProductPropertyArray": [
{
"Property1": 1,
"Property2": 3
},
{
"Property1": 4,
"Property2": 2
}
]
}
[
}
I've tried: 我试过了:
myapi.com/Products?$filter=length(ProductPropertyArray) eq 0
But this doesn't work because it wants a string. 但这不起作用,因为它需要一个字符串。
I've also tried 我也尝试过
myapi.com/Products?$filter=ProductPropertyArray eq null
But that doesn't work either. 但这也不起作用。
像这样调用api时,请在头脑中使用Prefer = Prefer ='odata.include-annotations =“ *”,return = representation'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.