ParameterExpression a = Expression.Parameter(typeof(int), "a");
MethodCallExpression _default = Expression.Call(
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }),
Expression.Constant("a != 1 && a = 2"));
SwitchCase case1 = Expression.SwitchCase(
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }),
Expression.Constant("a == 1")),
new ConstantExpression[] { Expression.Constant(1) }
SwitchCase case2 = Expression.SwitchCase(
typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }),
Expression.Constant("a == 2")),
new ConstantExpression[] { Expression.Constant(2) }
SwitchExpression _switch = Expression.Switch(a, _default, new SwitchCase[] { case1, case2 });
Expression<Action<int>> lambda = Expression.Lambda<Action<int>>(_switch, a);