9

Maybe I'm missing something obvious, but I how can I view the expression tree for this query:

from word in "The quick brown fox jumps over the lazy dog".Split()
orderby word.Length
select word

using LINQPad?

GuyBehindtheGuy
  • 1,368
  • 2
  • 17
  • 36

3 Answers3

10

You can view the objects that make up the expression tree as follows:

(from word in "The quick brown fox jumps over the lazy dog".Split().AsQueryable()
orderby word.Length
select word).Expression
Joe Albahari
  • 30,118
  • 7
  • 80
  • 91
1
from word in "The quick brown fox jumps over the lazy dog".Split().AsQueryable()
orderby word.Length
select word

Then press the λ button next to Results.

EDIT: This will let you see the lambda expression, but I can't seem to find the expression tree in the sense of the Expression Tree Visualizer. Allegedly LINQPad has (had?) one, but I'm not finding it either.

TrueWill
  • 25,132
  • 10
  • 101
  • 150
1

You can also use the .Dump() method available on all objects inside LinqPAD to dump an expression tree into the results window.

Bruno Lopes
  • 2,917
  • 1
  • 27
  • 38