简体   繁体   English

如何编写OData调用以获取具有等于空数组的特定属性的所有实体

[英]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.

相关问题 如何通过Strongloop环回中的rest调用获取特定的属性名称 - how to get specific property name via rest call in strongloop loopback 如何确保所有WebAPI / OData请求都与特定用户有关? - How to ensure that all WebAPI/OData requests pertain to a specific user? OData 获取单个属性:~/entityset/key/navigation/property - OData get individual property: ~/entityset/key/navigation/property odata如何知道ID是哪个属性? - How does odata know which property is the ID? 如何调用 Dynamics 365 OData 端点以从 Delphi 获取用户列表 - How to call the Dynamics 365 OData endpoint to get a list of users from Delphi Odata $filter 总是返回带有节点 js 和 postgresql 的空数组 - Odata $filter always returns empty array with node js and postgresql 使用自定义属性数组( $expand )过滤 oData 并将 $filter 用于特定属性 - Filter oData with array of custom attribute ( $expand ) and use $filter for a specific attribute 如何在 1C 中通过 OData 获得额外的道具? - How to get additional props by OData in 1C? 获取意图,实体,上下文和所有数据 - Get intents, entities, contexts and all data 如何使用单个 OData POST 创建多个实体到业务中心 Web 服务? - How to create multiple entities using a single OData POST to a Business Central Web Service?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM