Expression Tree Learn how to execute dynamic code at runtime using Expression Tree.

int num = 60;

var testCondition = Expression.Constant(num > 10);
var ifTrueBlock = WriteLineExpression("num is greater than 10");
var ifFalseBlock = WriteLineExpression("num is less than or equal to 10");

var ifThenElseExpr = Expression.IfThenElse(
    testCondition,
    ifTrueBlock,
    ifFalseBlock);

Expression.Lambda<Action>(ifThenElseExpr).Compile()();

What&#39;s Expression Tree

What's Expression Tree

In .NET, an expression tree is a tree-like data structure, where each node is an expression, for example, a method call or a binary operation such as x < y.

Need more performance?

Need more performance?

Find out how to dramatically improve EF performances with
Entity Framework Extensions

Where can I find online examples?

Where can I find online examples?

Online examples are now available!

Online Examples