OData / OData/AspNetCoreOData

$apply aggregation on nested collection not working or combined with Param $expand also not functioning

Open
#467 3 comments 1 reaction 1 assignee View on GitHub

@KenitoInc is already working on this.

Since Feb 8, 2022.

investigating
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

Please check the repository (Sample Project) : https://github.com/padhumailin/ODataV8Demo

Parent entity Accounts has a collection property LinkedAccounts Entity, I need to apply aggregation on collection property

filter on collection is working:
http://localhost:34987/api/accounts?$filter=LinkedAccounts/any(a:a/LinkedAccountName eq 'Loan1')

aggregation on parent entity also working:
http://localhost:34987/api/accounts?$apply=groupby((AccountType), aggregate($count as total))

aggregation on collection property not working
http://localhost:34987/api/accounts?$apply=groupby((LinkedAccounts/ParentId),%20aggregate($count%20as%20OrderCount))

http://localhost:34987/api/accounts?$expand=LinkedAccounts($apply=groupby((ParentId),%20aggregate($count%20as%20OrderCount)))

ERROR:
{"error":{"code":"","message":"The query specified in the URI is not valid. The parent value for a property access of a property 'ParentId' is not a single value. Property access can only be applied to a single value.","details":[],"innererror":{"message":"The parent value for a property access of a property 'ParentId' is not a single value. Property access can only be applied to a single value.","type":"Microsoft.OData.ODataException"

Expected Result:
[{"ParentId":"1","total":3},{"ParentId":"2","total":3},,{"ParentId":"3","total":3}]

Any suggestion on how to implement the EDM model or any diiferent way to write odata parameters to acheive

Environment:
Net 6
OData 8.0.4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.