gpt4 book ai didi

odata - 如何使用 web api odata 获取子记录的总和?

转载 作者:行者123 更新时间:2023-12-01 05:07:49 26 4
gpt4 key购买 nike

如何在 web api odata 中返回 OrderItems 的总价格 (ItemTotalPrice)?

看起来 web api odata 不支持 $apply,如下所述:http://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs01/odata-data-aggregation-ext-v4.0-cs01.html#_Aggregation_Methods_1

我有一个 web api odata 查询,如:

http://localhost:29446/odata/OrderItems

它返回以下 json:
{
"odata.metadata": "http://localhost:29446/odata/$metadata#OrderItems",
"value": [{
"OrderItemID": 17,
"ItemDescription": "test",
"ItemQty": 1,
"ItemUnitPrice": "1.10",
"ItemTaxGroup": 1,
"ItemTotalTax": "0.10",
"ItemTotalPrice": "1.22",
"ItemSubProgram": 1,
"ItemAccount": 1,
"ItemActualCost": "1.22",
"OrderID": 3
}, {
"OrderItemID": 18,
"ItemDescription": "test",
"ItemQty": 1,
"ItemUnitPrice": "1.10",
"ItemTaxGroup": 1,
"ItemTotalTax": "0.10",
"ItemTotalPrice": "1.10",
"ItemSubProgram": 1,
"ItemAccount": 1,
"ItemActualCost": "1.00",
"OrderID": 3
}, {
"OrderItemID": 19,
"ItemDescription": "test",
"ItemQty": 1,
"ItemUnitPrice": "1.10",
"ItemTaxGroup": 1,
"ItemTotalTax": "0.10",
"ItemTotalPrice": "1.10",
"ItemSubProgram": 1,
"ItemAccount": 1,
"ItemActualCost": "1.00",
"OrderID": 3
}, {
"OrderItemID": 20,
"ItemDescription": "test",
"ItemQty": 1,
"ItemUnitPrice": "1.10",
"ItemTaxGroup": 1,
"ItemTotalTax": "0.10",
"ItemTotalPrice": "1.10",
"ItemSubProgram": 1,
"ItemAccount": 1,
"ItemActualCost": "1.00",
"OrderID": 3
}, {
"OrderItemID": 21,
"ItemDescription": "test",
"ItemQty": 1,
"ItemUnitPrice": "1.10",
"ItemTaxGroup": 1,
"ItemTotalTax": "0.10",
"ItemTotalPrice": "1.10",
"ItemSubProgram": 1,
"ItemAccount": 1,
"ItemActualCost": "1.00",
"OrderID": 3
}]
}

我认为以下可能有效:
http://localhost:29446/odata/OrderItems?$apply=aggregate(ItemTotalPrice with sum as Total)

但我收到以下错误:
The query parameter '$apply' is not supported.

我正在使用 OData v4 和 Web API 2.2

最佳答案

数据聚合扩展尚未在 OData v4 的 Web API 2.2 中实现。 .NET OData 库的 Github 存储库上有一个对 ODataLib 级别实现的拉取请求:https://github.com/OData/odata.net/pull/6 但尚未合并到主分支中。

关于odata - 如何使用 web api odata 获取子记录的总和?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27134342/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com