OData / odata.net

ODataLib: Open Data Protocol - .NET Libraries and Frameworks
https://docs.microsoft.com/odata
Other
686 stars 349 forks source link

ODATA v4: Error when using $count for $orderby, $filter and $expand in navigational properties #809

Open GODBS opened 7 years ago

GODBS commented 7 years ago

Short summary (3-5 sentences) describing the issue.
$count does not seem supported in filter, expand or orderby for navigational properties.

Assemblies affected

OData.NET 7.X

Reproduce steps

http://services.odata.org/V4/TripPinService/People?$orderby=Friends/$count http://services.odata.org/V4/TripPinService/People?$filter=Friends/$count gt 0 http://services.odata.org/V4/TripPinService/People?$expand=Friends/$count

Expected result

What would happen if there wasn't a bug.
You should be able to see the count in the navigational properties according to the following document http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html#_Toc453752359

Actual result

What is actually happening.
Internal server error & bad request with the following error: "message": "Found system token '$count' in select or expand clause 'Friends/$count'.", "message": "The parent value for a property access of a property '$count' is not a single value. Property access can only be applied to a single value.",

GODBS commented 7 years ago

https://github.com/OData/WebApi/issues/194 https://github.com/OData/odata.net/issues/440 https://github.com/OData/odata.net/issues/298

All these issues are closed however i still can't seem to get it working in my application nor in the example... am i doing something wrong?

joshcomley commented 6 years ago

If you call ParseSelectAndExpand() on ODataQueryOptionParser with a $count $expand, you get the error you've seen. It seems at the moment odata.net is unable to parse such expands.

Does anyone have an update on this? It's still the case with the week old 7.4 beta.

rcreynolds53 commented 6 years ago

I am trying to do a count on an expand as well and still doesn't seem to be working. Any update on this?

NetTecture commented 6 years ago

Yeah. Any update? Running into the same here trying to put Odata into productio. Alternatives are adding it to a "Statistics" contained entity with all kinds of counts or actually using OData. Sadly this regression makes it unable to actually with counting navigational properties.

Mortana89 commented 5 years ago

Same here, simple count of navigational properties are not working.

robertmclaws commented 4 years ago

@mikepizzo I kow the team has been working on expanded $count support across the board... I just tried to do an $expand=NavigationCollection/$count and it failed in 7.2.2. Any idea when this will be supported?