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.





Thanks.
I started using this but Any and All was not working with ReflectionProvider on Linq To SQl. and is failig with following error. Any pointers in how to fix this.
Unhandled Exception: System.Data.Services.Client.DataServiceQueryException: An error occurred while processing this request. —> System.Data.Services
.Client.DataServiceClientException:
An error occurred while processing this request.Argument types do not matchSystem.ArgumentException at System.Linq.Expressions.Expression.Condition(Expression test, Expressio
n ifTrue, Expression ifFalse)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitConditional(ConditionalExpression c)
at System.Data.Linq.SqlClient.ExpressionVisitor.Visit(Expression exp)
at System.Data.Linq.SqlClient.Funcletizer.Localizer.Visit(Expression exp)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitMethodCall(MethodCallExpression m)
at System.Data.Linq.SqlClient.ExpressionVisitor.Visit(Expression exp)
at System.Data.Linq.SqlClient.Funcletizer.Localizer.Visit(Expression exp)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitLambda(LambdaExpression lambda)
at System.Data.Linq.SqlClient.ExpressionVisitor.Visit(Expression exp)
at System.Data.Linq.SqlClient.Funcletizer.Localizer.Visit(Expression exp)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitUnary(UnaryExpression u)
at System.Data.Linq.SqlClient.ExpressionVisitor.Visit(Expression exp)
at System.Data.Linq.SqlClient.Funcletizer.Localizer.Visit(Expression exp)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitMethodCall(MethodCallExpression m)
at System.Data.Linq.SqlClient.ExpressionVisitor.Visit(Expression exp)
at System.Data.Linq.SqlClient.Funcletizer.Localizer.Visit(Expression exp)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitMethodCall(MethodCallExpression m)
at System.Data.Linq.SqlClient.ExpressionVisitor.Visit(Expression exp)
at System.Data.Linq.SqlClient.Funcletizer.Localizer.Visit(Expression exp)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
at System.Data.Linq.SqlClient.ExpressionVisitor.VisitMethodCall(MethodCallExpression m)
at System.Data.Linq.SqlClient.ExpressionVisitor.Visit(Expression exp)
at System.Data.Linq.SqlClient.Funcletizer.Localizer.Visit(Expression exp)
at System.Data.Linq.SqlClient.Funcletizer.Funcletize(Expression expression)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Collections.IEnumerable.GetEnumerator()
at System.Data.Services.Internal.ProjectedWrapper.EnumerableWrapper.System.Collections.IEnumerable.GetEnumerator()
at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)
at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService, IODataResponseMessage respons
eMessage)
at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)
at System.Data.Services.DataService`1.HandleRequest()
at System.Data.Services.Client.QueryResult.ExecuteQuery(DataServiceContext context)
at System.Data.Services.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)
From the stack trace it appears that you are using WCF Data Services and Linq to SQL. Is this related to the Linq2Rest implementation I outlined above or the asp.net web api fork? If not and you are just using WCF Data Services then you are better off contacting Microsoft with your query. Thanks,
Pete
Just to add to Pete’s comment: Have you tried unit testing with an equivalent All query you wrote yourself and passed directly to your data service?
The Linq2Rest component will generate valid Any/All queries, but makes no guarantees that another component is able to consume them.