0

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 -

  • message": "The query specified in the URI is not valid. Could not find a property named 'BIAsset' on type 'Portal.Models.Entities.AssetUsage'.",

  • "innererror":

    -"message": "Could not find a property named 'Asset' on type 'Portal.Models.Entities.AssetUsage'.",

    -"type": "Microsoft.OData.ODataException",

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

}
Sac
  • 35
  • 9

1 Answers1

0

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

Sac
  • 35
  • 9