Peter Goodman bio photo

Peter Goodman

A developer living in Auckland building software using all sorts of bits and pieces I find along the way. Originally from Northern Ireland.

Twitter Google+ LinkedIn Github

WCF Data Services 5 has been RTM’d and adds support for a whole bunch of scenarios:

  • Any/All
  • Actions
  • Collections
  • Named Streams/Stream Properties
  • PATCH Verb
  • Prefer Headers
  • Properties on Derived Types
  • Support for DateTimeOffset and TimeSpan Data Types
  • Support for DbContext as the DataService Source
  • Spatial
  • Vocabularies

The most interesting bit for me initially was Any/All. Basically this has been one of those things that I get asked from time to time and have to explain that you could not (until now) filter a entity set based on some values in a sub-collection. E.g. give me all the customers who have ordered “x”.

With the inclusion of Any and All the following code is now possible

// http://foo/?filter=Orders/any(o: o/OrderItems/any(i: i.Id eq 5))
var customers = Customers
                .Where(c => 
                    c.Orders.Any(o => 
                        o.OrderItems.Any(i =>     
                            i.Id == 5));

 

I like the lambda syntax in the URI $filter parameter. It makes it easy for anyone that is used to modern languages to see what is going on.

So right now you can get WCF Data Services 5 and start using the Any/All support in OData.

Jacob Reimers has also gracefully accepted and published my pull request so Linq2Rest now fully supports Any/All queries in both the server and client APIs.

I’ve also submitted an issue on the ASP.Net Web API for support so please up vote that issue if it’s something that’s important to you. From that issue you can also go see the implementation that I’ve done for my fork of aspnetwebstack that implements server support for Any/All in ASP.Net Web API.