I’m working on an app using a WCF server (using the new beta Mindscape LightSpeed ORM) and consuming the service at an ASP.NET MVC2 client. My entities show up at the client as array of T, or IEnumerable<T>. I want to do cool things with the data after it has arrived, but the LINQ syntax required IQueryable<T>.
I know there is a way to convert from IEnumerable<T> to IQueryable<T>, but I have had no luck so far searching for it. Can anybody help?
Thanks,
Dave
Well, I suspect you’re thinking of
Queryable.AsQueryable()– but what makes you think that you need to useIQueryable<T>to use LINQ? Converting anIEnumerable<T>toIQueryable<T>won’t give you most of the benefits ofIQueryable<T>.LINQ to Objects is all based around
IEnumerable<T>. If you’re happy working with the data you’ve already received, that’s all you need.If, however, you want to express a query at your client and tell the WCF server to execute that query (e.g. performing the filtering in the database or at least at the WCF side), that’s when you’d use
IQueryable<T>. You might find my Edulinq post aboutIQueryable<T>useful. You’d need some way of representing the service as anIQueryable<T>though – and at that point you’re beyond my WCF knowledge.