The One With

OData Provider for XPO – GroupBy(), Count(), Max() and More…

OData + !summary ExtensionsLast time I have introduced you to a custom OData extension !summary. But as exciting as it was, the standard .NET Data Client Library does not support it. Why should it right? It does not know about it. To solve this, the eXpress Persistent Objects (XPO) Toolkit now includes a client side library that can understand and work with all the extensions that we make.

The AtomPubQuery<> (similar to the .NET DataServiceQuery<>) will also support all the basic OData operations like $filter, $orderby etc… Let’s see how to use it.

Let’s assume you have an OData service exposing data from the Northwind Database and you want to get top 5 sales broken down by country.

AtomPubQuery<Order> Orders {
    get {
        return new AtomPubQuery<Order>(
            new Uri("http://localhost:54691/Northwnd.svc", UriKind.Absolute), 
            "Orders", 
            "OrderID", 
            this);
    }
}
var query = from o in Orders
            group o by o.ShipCountry  into g
            orderby g.Count() descending
            select new Sale() { Country = g.Key, Total = g.Count() };
this.chartControl1.DataSource = query.Take(5).ToList();
 
OData feed bound to a Chart Control 

This will make the following request:

http://localhost:54691/Northwnd.svc/Orders?!summary=ShipCountry,Count() desc&$top=5

and execute the following query on the server:

select top 5 ShipCountry, count(*) from Orders group by ShipCountry order by count(*) desc

Pretty cool ah? :)

Cheers,

Azret

Published Aug 15 2010, 01:13 PM by
Filed under: , , ,
Bookmark and Share

Comments

No Comments
LIVE CHAT

Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

FOLLOW US

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

Copyright © 1998-2017 Developer Express Inc.
All trademarks or registered trademarks are property of their respective owners