【发布时间】:2010-08-11 10:57:48
【问题描述】:
让有:
Expression<Func<Customer, bool>> expression = c => c.Name == "John";
现在我通过使用:
string myvalue = ((ConstantExpression) bin.Right).Value;
现在有:
string x = "John";
Expression<Func<Customer, bool>> expression = c => c.Name == x;
现在我明白了
string myvalue = ((ConstantExpression) bin.Right).Value;
会产生错误,因为这里的 bin.right 不是常量表达式,而是字段表达式,但问题是我如何从中获取值(John)?
【问题讨论】:
标签: c# lambda expression-trees