Have you ever encountered the need to see how Expression Trees are built but you are working with a collection of memory objects and not LINQ to SQL?
First, you should try to download the Expression Tree Visualizer for Visual Studio. You can find a nice post about it @ http://blogs.msdn.com/charlie/archive/2008/02/13/linq-farm-seed-using-the-expression-tree-visualizer.aspx
You can also try LINQPad, since it has a pretty good Expression Tree Visualizer. You can download LINQPad from http://www.linqpad.net/. LINQPad allows you to create code-snippets (very useful for creating temporary ad-hoc queries to try stuff out).
Now back to my original question…
After you have set up the Expression Tree Visualizer for Visual Studio, you can see the expression tree for a LINQ to SQL query in the debugger – cool. Now, you write a LINQ to Objects query and attempt to view the expression tree in the debugger – oh, oh, there is no expression tree visible!
The simplified explanation is that LINQ to SQL uses IQueryable as the data source while LINQ to Objects uses IEnumerable. Therefore, in order to fix this issue, all you need to do is call the extension method AsQueryable() on your in-memory data source. Now, when you use the debugger, you will be able to see the expression tree that was generated!
Happy LINQin’ :)