WebApi
WebApi copied to clipboard
Using apply & expand in combination does not work
Using apply and expand together does not work.
According to the OData aggregation spec, this query syntax should work
$apply=expand(Sales,filter(Amount gt 3))
But in the results, the expanded entity set is not included at all.
According to https://github.com/OData/odata.net/pull/1277 this query syntax should work:
$expand=Orders($apply=aggregate(Weight with sum as Total))
But when using this syntax the expanded entity set is present, but the aggregation is not applied, all of the child entities are included in full.
Have I got the query syntax correct, or is this a bug?
Assemblies affected
Microsoft.OData.Core & Microsoft.OData.Edm - v7.6.3 Microsoft.AspNet.OData - v7.3.0
Reproduce steps
Use the queries:
$apply=expand(Sales,filter(Amount gt 3))
$expand=Orders($apply=aggregate(Weight with sum as Total))
Expected result
- The first example query above should expand out the child Sales entities.
- The second example query should expand out the orders and aggregate them into a single result with a total weight.
Actual result
- The first query does not show any expansion.
- The second query shows an unaggregated expansion.
@SimonPStevens In my memory,
$apply=expand(Sales,filter(Amount gt 3)) $expand=Orders($apply=aggregate(Weight with sum as Total))
both supports in ODL, it means it supports to parse the query into token/AST.
But, it's not supported yet in ASP.NET (Core) OData. It means it's not supported to build the LINQ expression based on Token/AST.
Thanks @xuzhg
Do you know if this feature is planned or being worked on?
If not I'm interested in helping out with the dev effort.
@SimonPStevens Thanks for your interesting. As i know, @kosinsky is working on $apply=expand(....).
for $apply in $expand, i didn't get any message form @kosinsky. So, We are welcome your contribution on this part. Maybe you can just start from here: https://github.com/OData/WebApi/blob/master/src/Microsoft.AspNet.OData.Shared/Query/Expressions/SelectExpandBinder.cs#L692
Meanwhile. I'd like @kosinsky can give us input.
I'm working on $apply inside $expand too. These two features are related.
Thanks guys. If it's already being worked I'll leave you to it. I'm happy to try out a nightly build when it's getting close if you want me to test my use cases.
@kosinsky, is there any progress on this? Thanks!
@kosinsky Hi I am curious as well if there is any progress. Thank you.
@kosinsky @xuzhg
I tesed with Odata version 8.0.4, still $expand and $apply not works in combination
3 years and 3 .NET versions later, still no progress. I hope you can get to fixing this soon...
@xuzhg Is there any update on the issue?