How to use anonymous types with Netflix OData API

Posted by obautista on Stack Overflow See other posts from Stack Overflow or by obautista
Published on 2010-12-28T23:20:54Z Indexed on 2010/12/29 0:54 UTC
Read the original article Hit count: 217

Filed under:
|

If I create this collection:

IEnumerable<_TITLE> _titles = null;

How can I set the result set from Netflix in this expression:

_titles = from t in Titles where t.Id == "ApUFq" select new {t, t.Cast}

I am getting:

Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Collections.Generic.IEnumerable<_Title>'. An explicit conversion exists (are you missing a cast?)

I understand it's because I am using an anonymous type. _TITLE is a custom complex object I create that exposes a subset of Netflix properties.

If I add "_TITLE" in front the of the "new" it says that my object does not implement IENUMBERABLE.

If then _TITLE implements IENUMBERABLE, it says _TITLE does not contain a definition for ADD and still getting conversion error.

Basically, I want to set the _TITLE properties with the data returned from Netflix. I have defined _TITLE to contain the fields I need, plus a collection of PERSON (for Cast).

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about OData