Within the context of C# on .Net 4.0, are there any built-in objects that implement IQueryable<T>?
Within the context of C# on .Net 4.0, are there any built-in objects that
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
IQueryableobjects are produced by Queryable Providers (ex. LINQ to SQL, LINQ to Entities/Entity Framework, etc). Virtually nothing you can instantiate withnewin the basic .NET Framework implements IQueryable.IQueryableis an interface designed to be used to create Queryable providers, which allow the LINQ library to be leveraged against an external data store by building a parse-able expression tree. By nature, Queryables require a context – information regarding what exactly you’re querying. Usingnewto create any IQueryable type, regardless of whether it’s possible, doesn’t get you very far.That being said, any
IEnumerablecan be converted into anIQueryableby using theAsQueryable()extension method. This creates a superficially-similar, but functionally very different construct behind the scenes as when using LINQ methods against a plainIEnumerableobject. This is probably the most plentiful source of queryables you have access to without setting up an actual IQueryable provider. This changeover is very useful for unit-testing LINQ-based algorithms as you don’t need the actual data store, just a list of in-memory data that can imitate it.