首页 > 解决方案 > 带有 where 和 sum 的 Odata

问题描述

我正在开发 asp.Net-Core 应用程序。我需要发出转换为 SQL 的 ODATA 请求:

SELECT SUM(GameCount) 
   FROM [GameReportDaily] 
  where [StartTimeUtc]>'2019-05-13 22:00:00.0000000'

我可以提出要求

/odata/GameReportDaily?$apply=aggregate(gameCount%20with%20sum%20as%20Total)

没有过滤器,它工作正常。现在我需要添加过滤器,但它不起作用:

/odata/GameReportDaily?$apply=aggregate(gameCount%20with%20sum%20as%20Total1)&$filter=(StartTimeUtc+ge+2019-05-27T18%3A00%3A00.000Z)+and+(StartTimeUtc+le+2019-05-28T18%3A00%3A00.000Z)

回复:

"Message": "在 URI 中指定的查询无效。属性或路径 StartTimeUtc 在当前上下文中不可用。它在早期的转换中被删除。",

我怎样才能像上面的 SQL 一样发出 ODATA 请求?

标签: c#restasp.net-coreodata

解决方案


推荐阅读