Query generation issues when using ODATA
See original GitHub issueWorked through a few more of my ODATA examples, I’ve discovered a few further issues with query generation when using Microsoft ODATA WebApi (https://github.com/OData/WebApi) for .net core 3.1. I’m using a build from commit 8cd544b for linq2db in the master branch with the fix for #2070
Sample project here: https://github.com/djkunkel/linq2db-aggregate-odata-sample
The following requests fails to generate SQL:
Without orderby:
/odata/People?$apply=groupby((Title),aggregate(YearsExperience with countdistinct as Test))
With orderby:
/odata/People?$apply=groupby((Title),aggregate(YearsExperience with sum as TotalExperience))&$orderby=TotalExperience
/odata/People?$apply=groupby((Title),aggregate(YearsExperience with min as Test))&$orderby=Test
/odata/People?$apply=groupby((Title),aggregate(YearsExperience with max as Test))&$orderby=Test
/odata/People?$apply=groupby((Title),aggregate(YearsExperience with average as Test))&$orderby=Test
/odata/People?$apply=groupby((Title),aggregate(YearsExperience with countdistinct as Test))&$orderby=Test
The following cases do work for reference:
/odata/People?$apply=groupby((Title),aggregate(YearsExperience with sum as Test))
/odata/People?$apply=groupby((Title),aggregate(YearsExperience with average as Test))
/odata/People?$apply=groupby((Title),aggregate(YearsExperience with min as Test))
/odata/People?$apply=groupby((Title),aggregate(YearsExperience with max as Test))
/odata/People?$apply=groupby((Title),aggregate($count as NumPeople))&$orderby=NumPeople
/odata/People?$apply=groupby((Title),aggregate($count as NumPeople))&$count=true
/odata/People?$apply=filter(Title eq 'Engineer' or Title eq 'QA')/groupby((Title),aggregate($count as NumPeople))&$count=true
/odata/People?$apply=groupby((Office/Name),aggregate($count as NumPeople))&$count=true
/odata/People?$apply=filter(Title eq 'QA')/groupby((Office/Id,Office/Name),aggregate($count as NumPeople))&$count=true&$orderby=NumPeople desc
/odata/people?$expand=Office
Thank you for this project again!
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
ODATA Date Filter - Generating sql server query differently ...
ODATA Date Filter - Generating sql server query differently than expected - causing poor performance · There are three versions of EF Core....
Read more >Get Items with ODATA Query Suddenly Failing
Solved: Hi all, I have a Flow that runs daily and uses several SharePoint Get Items actions, each with a different ODATA query....
Read more >Issue while consuming BI query in OData service
While consuming BI query into OData service I am facing some issues. Details of the issues are as follows : Following this blog....
Read more >Using OData.Feed and the Query option to avoid the dynamic ...
In my last post I showed how, in many cases, you can avoid the “dynamic data sources” error with OData data sources by...
Read more >Why not OData?
There is virtually no contract. · The interface errs on the side of being too liberal in what it will accept. · The...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@djkunkel, version 2.9.7 will be released on Thursday. Dsitinct.Count queries will work but hey have non optimal SQL generation. If you expect
COUNT (DISTICT x)
- pity that it is not ready yet but i’m working on it.I see, one team creates something not compatible with others. But I saw in OData code hacks for each EF version. Workarounds can not help if there are no test cases on EF side.
Anyway OData team are also clever guys, they have defined dynamic aggregation without generating run-time classes on the fly. I was surprised with the idea to just inject into JSON serialization with specially prepared classes.