使用扩展无法对内部数组数据进行Odata过滤

时间:2019-12-24 06:43:48

标签: c# asp.net json api odata

我想过滤我从API获得的JSON集。尝试过的Odata会展开以进行过滤,但无法正常工作。我只想过滤Parameters / Display1值1。

URL:http://localhost/MyApp/DataService/Products/CQ.GetProducts(ProductType=3)$expand=Parameters($filter=Display1 eq 1)

 "message": "The type 'Configuration.ProductInfo' is not an entity type. Only entity types support $select and $expand.\r\nParameter name: context"

    {
  "@odata.context": "http://localhost/MyApp/DataService/$metadata#Collection(Configuration.ProductInfo)",
  "value": [
    {
      "Id": 30102,
      "ProductParentId": 30101,
      "ProductTypeId": 3,
      "Description": "",
      "Name": null,
      "IsEnabled": true,
      "Parameters": [
        {
          "ProductId": 30102,          
          "Description": "A2",         
          "Display1": 1
        },
        {
          "ProductId": 30102,          
          "Description": "A1",         
          "Display1": 0
        },
        {
          "ProductId": 30102,          
          "Description": "A4",         
          "Display1": 1
        },
        {
          "ProductId": 30102,          
          "Description": "A3",         
          "Display1": 0
        }
      ]
    },
    {
      "Id": 30201,
      "ProductParentId": 30002,
      "ProductTypeId": 3,
      "Description": "",
      "Name": null,
      "IsEnabled": true,
      "Parameters": [
        {
          "ProductId": 30101,          
          "Description": "A3",         
          "Display1": 0
        },
        {
          "ProductId": 30101,          
          "Description": "A3",         
          "Display1": 0
        },
        {
          "ProductId": 30101,          
          "Description": "A3",         
          "Display1": 0
        },
        {
          "ProductId": 30101,          
          "Description": "A3",         
          "Display1": 0
        }
      ]
    }
  ]
}

此问题还有其他解决方案吗?

0 个答案:

没有答案