It’s a problem, when you work with Expression types in any way, to understand the structure of complex expressions and possibly recreate them. After all, there are 46 entries in the ExpressionType enum, many of them corresponding to their own Expression-derived type, all of those with their own specific properties… in other words, it’s not entirely intuitive.

To help visualization of Expressions, I have created the ExpressionDumper, which outputs any expression (by default) in a nice hierarchical way on the console. It shouldn’t be too hard to use the class with other output targets, and I’m placing it under GNU LGPL license for others to use (that allows commercial use, in case you’re not quite on top of all the various open source licenses). I’d appreciate being kept up to date with any further development you may do on it, but you don’t have to tell me if you don’t want to. With this source code

Expression<Predicate<Product>> expression = p => p.UnitPrice > 10;
ExpressionDumper.Output(expression);

the ExpressionDumper is going to produce this output (of course this is a very simple example, chosen for brevity):

LambdaExpression (
  Parameters:
    ParameterExpression (p)
  Body:
    BinaryExpression:GreaterThan (
      Method: Boolean op_GreaterThan(System.Decimal, System.Decimal)
      Left:
        MemberExpression Product.UnitPrice (
          Expression:
            ParameterExpression (p)
        )
      Right:
        ConstantExpression (10)
    )
)

Without further ado, here’s the download: ExpressionDumper.zip

Have fun!