日期:2014-05-17 浏览次数:20920 次
//Expression<Func<A, A>> f = a => a.cont >= 23 ? a : null;
var par = Expression.Parameter(typeof(A), "a");
var ex = Expression.Lambda(Expression.Condition(Expression.Equal(MemberExpression.Property(par, "cont"), Expression.Constant(23, typeof(int))), par, Expression.Constant(null, typeof(A))), par);
var s = (ex.Compile() as Func<A, A>)(new A() { cont = 2 });