- Arithmetic Operations
- Assign Expression
- Comparison Expression
- Conditional Expression
- Exception Expression
- Iteration Expression
- Jump Expression
- Logical Expression
- Member Expression
- Operators Expression
Expression Tree Tutorial OrElse
You can build an expression tree using Expression.OrElse
method which contains a conditional OR operation that evaluates the second operand only if the first operand evaluates to false. For example, you have the following code.
bool value = false || true; Console.WriteLine(value);
Here is the code that is required to build the same functionality using expression tree.
Expression greaterThanExpr = Expression.OrElse( Expression.Constant(false), Expression.Constant(true) ); Console.WriteLine(Expression.Lambda<Func<bool>>(greaterThanExpr).Compile()());