odata.net
odata.net copied to clipboard
Support for GroupBy and Aggregate at OData Client
Actually the Microsoft OData Clients for .NET "OData Connected Service or OData v4 Client Code Generator" (Microsoft.OData.Client.dll[DataServiceQuery]) don't support making groupby and aggregate queries to consume the OData v4 service which already has support for those (See addicional details).
Assemblies affected
Microsoft.OData.Client.dll
Reproduce steps
- Create a OData v4 service with the version 5.9+ of the https://www.nuget.org/packages/Microsoft.AspNet.OData
or using RESTier (https://odata.github.io/RESTier/) or using WebApi (https://odata.github.io/WebApi/)
- Create a Client
or using the "OData Connected Service (https://visualstudiogallery.msdn.microsoft.com/b343d0eb-6493-44c2-b558-13a0408d013f)"
or using the "OData v4 Client Code Generator (https://visualstudiogallery.msdn.microsoft.com/9b786c0e-79d1-4a50-89a5-125e57475937)"
- Make a query which has a group by - Ex: "client.Users.GroupBy(user => user.Login).ToList();"
Expected result
http://localhost/odata/Users?$apply=groupby((Login));
Actual result
It throws "An unhandled exception of type 'System.NotSupportedException' occurred in Microsoft.OData.Client.dll - The method 'GroupBy' is not supported".
Additional details
Support for group by and aggregation on the service - https://github.com/OData/WebApi/issues/70
@jvitor83, I updated this issue.
Currently, OData client doesn't support aggregate.We would like to have it to be fixed in the ODataLib, but at this point we are spending all resources on a breaking changes release that have a hard deadline. So we want to know the priority of these issues on your side. We would happily accept your pull requests as well. So if you have time to implement this feature, we'd love to merge it into the library.
+1 OData has been great, but in order to meet new requirements we need aggregation or we'll have to implement something outside of OData.
Has there been any movement on this issue? Are there plans to include grouping functionality in the client?
Hello, is there any update on this issue?
I'm using Microsoft.AspNetCore.OData v7.1.0
and have a problem when trying to use groupby with aggregate functions, but just groupby itself works fine
Support for this feature is being added by the following PR: #1925