Reporting with ADO.NET Data Services and Telerik Report Viewer

Telerik has a range of controls that work with ADO.NET Data Services as the data source . Take a look at them here :

ADO.NET Data Services with Telerik Controls

Kevin Babcock has a great post over at Telerik where he talks about using ADO.NET Data Services with Telerik Reporting suite .

I wanted to address one small point in the blog post which I felt can be improved upon.

“You might be curious why I chose to iterate through the list of categories in the report parameter value, calling the web service for each one and appending the results to a collection.
The reason is that, due to the limitations of ADO.NET Data Services, you can’t use methods like Contains to filter data in your LINQ queries.“

Yes , this is absolutely correct.
We don't support the “Contains” operator to select a primitive property of the Entity Type from a given range of values.
The client linq implementation doesn't support Contains on Navigation properties is because we don't have a URI Query operator  that corresponds to the "Contains" function to select a value from a set. But you can semantically achieve the same effect by “OR”ing a couple of “EQUALS” expressions.

ex:

If A={0,1,2,3}  , then A.Contains(B) is equivalent to ( B == A[0] OR B ==A[1] OR B == A[2])

I wrote about achieving this effect here :  Set Based Operations in Ado.net Data Services

Now, in this sample , we are filtering an Entity Set (Products) based on the value of a primitive property ( CategoryID ) of a Navigation Property (Categories).
Now , since this is the Northwind model Schema, Products are related to categories in a 1..M association and Categories to Products in a 1..M association.

What this means is that the above query can be expressed as : 

Now , this is still not as optimal as it can be , but we reduced the number of round trips as we download only relevant categories and their associated Products.
To make this even easier , we use the IsIn<T> extension method I wrote from Set Based Operations in Ado.net Data Services.

So , there you have it , we reduced the number of network calls and also the lines of code to achieve this filtering.

On a side note , Kevin has left Telerik and now blogs at : https://www.myviewstate.net/blog/

All the best for your future endeavours Kevin !!