group-byodataaggregationodata-v4microsoft-odata

Odata V4 group by with Top and skip not working


I am not able to get groupby to work with top and skip which should be most simplest thing. I am fetching data using OData and able to get output using the query below

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

Output of the above query

However when I try to apply skip or top on the above generated output, I get an error mentioned below

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

Error -

Entity class structure

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; }

}

Solution

  • I was using EnableLowerCamelCase() so I need to use exact casing while writing a query. However in future update this issue will be resolved. refer to below URL for further updates. https://github.com/OData/WebApi/issues/1659