LINQ to Reflection IsNot LinqProvider by ThinqLinq

LINQ to Reflection IsNot LinqProvider

 

In one of the sessions I attended at DevLinq (er, DevLink), the presenter was discussing the providers that shipped with VS 2008. Among these, he included the standard LINQ to Objects, LINQ to XML, LINQ to SQL, LINQ to Entities and LINQ to Datasets. In addition, he added LINQ to Reflection which struck me as unusual, so I looked it up.

 

In this case, LINQ to Reflection isn't really a provider, but just a specific implementation of LINQ to Objects which happens to query reflection information. Consider the following query:

 

Dim query = From m In GetType(System.Linq.Enumerable).GetMethods _

                    Order By m.Name _

                    Select m

 

In this case, the underlying source (Type.GetMethods) returns an Ienumerable(Of MethodInfo) object. As such, it is just using the LINQ to Objects method. When I think of a LINQ provider implementation, I think of a mechanism that takes the LINQ expressions and translates the expressions or otherwise alters the underlying query implementation in some way. For example, LINQ to Sharepoint translates the LINQ expressions into OCAML and LINQ to Amazon uses custom query expressions to fetch results from an Amazon web service.

 

While I don't deny the power of being able to query over reflection, I would not want people to confuse it as a true provider.

Posted on - Comment
Categories: LINQ) - VB) -
comments powered by Disqus