OData Aggregation Extension on V4

Topics: ASP.NET Web API
Apr 4 at 10:57 AM
Edited Apr 6 at 4:54 PM
I would like to extend the Web API with some aggregation function. It would be great if it is already on the roadmap (could not find that). But I may also be able to contribute in this area.

Some background: http://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs01/odata-data-aggregation-ext-v4.0-cs01.html

What I am looking for is some more understanding of where to start extending this framework. From the source code alone I could not directly see how to add a queryoption. If someone could point me in the right direction.. this would be great.

I can extend the ODataQueryOption class to start supporting new odata uri options, but the aggregations would require an anonymous type to be returned. Any ideas on this?

Example:

/Blogs/$apply=groupby(Author/LastName, aggregate($count as BlogCount))

This should result in a count of blogs grouped by the LastName of the Author of the BlogEntry

{
"@odata.context": "$metadata#Blogs(Author(LastName),BlogCount",
"value": [
{ "@odata.id": null, "Author": { "LastName" : "Clancy" }, "BlogCount": 23 },
{ "@odata.id": null, "Author": { "LastName" : "Kirk" }, "BlogCount": 2 },
{ "@odata.id": null, "Author": { "LastName" : "George" }, "BlogCount": 12 }
]
}
May 17 at 12:07 PM
I am trying to do the same. Were you able to make any headway?
May 27 at 9:54 PM
I developed a LINQ extension that allows to do this: http://www.adaptivelinq.com
Using the AdaptiveLINQ .QueryByCube() method, the use of a projection leads to an aggregation effect.
Thus, the following C# code:
Blogs.QueryByCube(myBlogAnalysisCube)
        .Select(x => new {
          LastName = x.AuthorLastName,
          BlogCount = x.TotalCount
       }
will execute the query:
Blogs.GroupBy(x => x.Author.LastName)
        .Select(group => new {
          LastName = group.Key,
          BlogCount = group.Count()
       }
Exposing the IQueryable expression Blogs.QueryByCube(myBlogAnalysisCube) as an OData feed, you can query:
BlogsAnalysis/$select=AuthorLastName,TotalCount
Of Course, this projection can be combined with a filter or any other OData operator:
BlogsAnalysis/$select=AuthorLastName,TotalCount/$filter=AuthorLastName eq Clancy
Jun 4 at 9:11 AM
Could someone from the OData team please answer Powdor's questions? I have the exactly same interests on OData V4 Aggregation Extension.

Basically 2 questions:
(1) Is OData Aggregation on the todo list of OData team? What is the plan for it?
(2) Will it be open for contribution? If yes, how to get started?

Thanks a lot,
Karl
Jul 15 at 10:17 PM
would like to know to.
Developer
Jul 16 at 6:26 AM
  1. aggregation definitely is one of the key features we want to support. the feature is ducumented here. https://aspnetwebstack.codeplex.com/workitem/1786 Most likely we would want to start this work sometime late this year. it'd be refected on codeplex once we prioritize this feature.
  2. we are now in the process of making all odata projects truly "open source", which means all feature planning, bug triage, release are open to the community including taking contributions. we should open source at least one of our projects in Aug and gradually open all the others. we will announce this on odata team blog please watch it to get the latest status.