Traversing an expression tree
An Expression is a simple construct that represents a node in a tree. The expression has a node type, and the implementation decides what the node type expresses and means. This forms a tree that can be recursively traversed and reasoned about.
For lambda expressions, it means it has a body that consists of an expression that is of a specific type; this type could be a Binary Expression that holds a left and a right and the node itself representing the operand (equals, not equals, and so forth):
Figure 7.2 – Binary expression
Taking the example of the filter:
Expression<Func<int, bool>> filter = (i) => i >= 37;
Visually it looks like the following:
Figure 7.3 - A parameter larger than the constant expression
The operand is greater than or equal, the left-hand side accesses the parameter passed into it, and the right-hand side holds the constant value of 37.
...