使用 $apply 在 OData v4 规范中聚合过滤数据集的语法 [英] Syntax for Aggregating a Filtered Dataset in OData v4 Spec using $apply

查看:56
本文介绍了使用 $apply 在 OData v4 规范中聚合过滤数据集的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我正在使用以下架构查询名为 Sales 的数据集:

Suppose I am querying a dataset called Sales with the following schema:

id (int)价格(十进制)活动(位)

使用$apply 查询选项和OData v4 规范,什么是语法仅找到活跃销售的平均价格?

Using the $apply query option and the aggregate transformation of the OData v4 spec, what would be the syntax for finding the average price for only active Sales?

$apply 支持聚合和过滤转换,但我不知道如何组合它们,或者是否允许这样做.

$apply supports both aggregation and filter transformations, but I can't figure out how to combine them or if you're even allowed to do so.

谢谢!

推荐答案

$apply=filter(Status eq 1)/aggregate(price with average as averagePrice)

也许你可以参考现有的测试:

maybe you can refer the existing test:

https://github.com/OData/WebApi/blob/master/OData/test/E2ETest/WebStack.QA.Test.OData/Aggregation/AggregationTests.cs

https://github.com/OData/WebApi/blob/master/OData/test/UnitTest/System.Web.OData.Test/OData/Query/ApplyQueryOptionTest.cs

这篇关于使用 $apply 在 OData v4 规范中聚合过滤数据集的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆