views:

721

answers:

3

I'm playing around with the new Netflix OData feed (http://odata.netflix.com/Catalog/) and having some issues. I'm trying to learn LINQ at the same time but having difficulty doing what I thought was going to be quite simple.

I'd like to return a list of Titles that match a given Genre. The Titles object contains a collection of Genres. I'm not sure how to write this query. My attempt below does not appear to work using LINQPad.

from t in Titles
where t.Genres.Name.Contains("ABC")
select t
A: 

If you are receiving an DataServiceQueryException along with the message: Request version '1.0' is too low for the response. The lowest supported version is '2.0'.

You need to upgrade your version of .Net to .Net Framework 4 and download LINQPad for .NET Framework 4.0

Nicholas Murray
I'm using LINQPad v4.13.4 which I believe is the .net 4 version.
Kyle Russell
A: 

Kyke, This will get you a listing of all movies by Genre

(from g in Genres.Expand("Titles") where g.Name == "Horror" select g).Dump();

This creates the following URL in LinqPad /Catalog/Genres('Horror')?$expand=Titles

Its interesting that I needed to use the .Expand syntax to get it. When I browse to the netflix odata feed with my browser and want the same data I can get it with the following URL.

http://netflix.cloudapp.net/Catalog/Genres('Horror')/Titles

There must be a way to get at it without .Expand

Alex
You wrote Kyke, instead of Kyle
Danny G
+6  A: 

I was able to get my results using the LINQ:

from g in Genres
from t in g.Titles
where g.Name == "Horror"
select t

This way I don't need to use Expand. I can also use the URL: http://odata.netflix.com/Catalog/Genres('Horror')/Titles() to get the same results. This post by Chris Woodruff helped me understand the issue.

Kyle Russell