WebApi icon indicating copy to clipboard operation
WebApi copied to clipboard

Using apply & expand in combination does not work

Open SimonPStevens opened this issue 5 years ago • 10 comments

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 avatar Mar 11 '20 11:03 SimonPStevens

@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.

xuzhg avatar Mar 17 '20 18:03 xuzhg

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 avatar Mar 17 '20 19:03 SimonPStevens

@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.

xuzhg avatar Mar 18 '20 17:03 xuzhg

I'm working on $apply inside $expand too. These two features are related.

kosinsky avatar Mar 18 '20 20:03 kosinsky

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.

SimonPStevens avatar Mar 24 '20 13:03 SimonPStevens

@kosinsky, is there any progress on this? Thanks!

adzhiljano avatar Dec 11 '20 13:12 adzhiljano

@kosinsky Hi I am curious as well if there is any progress. Thank you.

Didjeeh avatar Dec 23 '21 12:12 Didjeeh

@kosinsky @xuzhg

I tesed with Odata version 8.0.4, still $expand and $apply not works in combination

padhumailin avatar Jan 26 '22 12:01 padhumailin

3 years and 3 .NET versions later, still no progress. I hope you can get to fixing this soon...

cyrtii avatar Mar 27 '23 16:03 cyrtii

@xuzhg Is there any update on the issue?

manishkbhalodiya avatar Dec 06 '23 13:12 manishkbhalodiya