【问题标题】:Odata V4 group by with Top and skip not workingOdata V4 group by with Top and skip 不工作
【发布时间】:2019-03-31 16:38:32
【问题描述】:

我无法让 groupby 与 top 和 skip 一起工作,这应该是最简单的事情。 我正在使用 OData 获取数据并能够使用下面的查询获取输出

https://localhost:6523/api/OData/AssetUsage/?$apply=groupby((assetId,BIAsset/name),aggregate(interactions sum as totalInteractions, uniqueInteractions sum as totalUniqueInteractions))&$orderBy=totalInteractions asc

Output of the above query

但是,当我尝试在上面生成的输出上应用 skip 或 top 时,我收到下面提到的错误

https://localhost:6523/api/OData/AssetUsage/?$apply=groupby((assetId,BIAsset/name),aggregate(总和为totalInteractions的交互,总和为totalUniqueInteractions的uniqueInteractions))&$orderBy=totalInteractions asc&$top=1

错误 -

  • message": "URI 中指定的查询无效。在“Portal.Models.Entities.AssetUsage”类型上找不到名为“BIAsset”的属性。",

  • “内部错误”:

    -"message": "在 'Portal.Models.Entities.AssetUsage' 类型上找不到名为 'Asset' 的属性。",

    -“类型”:“Microsoft.OData.ODataException”,

实体类结构

public class AssetUsage
{
    public int Id { get; set; }
    [ForeignKey("BIAsset")]
    public int? AssetId { get; set; }
    public int YearMonthId { get; set; }
    public int Interactions { get; set; }
    public int UniqueInteractions { get; set; }
    public DateTimeOffset Recency { get; set; }
    public virtual BIAsset BIAsset { get; set; }

}

【问题讨论】:

    标签: group-by odata aggregation odata-v4 microsoft-odata


    【解决方案1】:

    我使用的是 EnableLowerCamelCase(),所以我需要在编写查询时使用精确的大小写。 但是,在未来的更新中,这个问题将得到解决。 有关进一步更新,请参阅下面的 URL。 https://github.com/OData/WebApi/issues/1659

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-29
      • 2020-08-13
      • 2010-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-14
      相关资源
      最近更新 更多