OData / WebApi

OData Web API: A server library built upon ODataLib and WebApi
https://docs.microsoft.com/odata
Other
853 stars 476 forks source link

Ability to customize the aggregation #2194

Open pashokchakravarthi opened 4 years ago

pashokchakravarthi commented 4 years ago

BackGround : We are using Microsoft.aspnetcore.odata v7.4.0 package in .net core api to apply filtering, ordering, paging & column selection on flat data returned by api.

Requirement : We have to implement data aggregation and return the aggregated data along with original data. Sample screenshot for reference: o1

SubTotal and GrandTotal rows indicates aggregated data. As we have paginated data in client side, using odata for aggregation is the only option. From https://devblogs.microsoft.com/odata/aggregation-extensions-in-odata-asp-net-core/ it is clear that odata supports data aggregtion similar to sql groupby but it doesnt return the combined result set of aggregated and detail data.

We would like to know if there is any way to customize the result set of EnableQueryAttribute, to accomodate this requirement. Or Can we use this library just for filtering, ordering & column selection on flat data? On top of this result set, we would like to implement custom aggregation.

xuzhg commented 4 years ago

@kosinsky any input here?

kosinsky commented 4 years ago

In current implementation we will need to send two OData queries: one for aggregated data and one for flat data. OData specifications supports hierarchies and roll ups, but it isn't implemented yet.