0

我很难掌握表达式树。我希望能够为以下语句手动构建表达式树:

c => c.Property

很多教程都集中在比较上,而我只希望它返回这个属性。有什么帮助吗?

4

1 回答 1

3
ParameterExpression parameter = Expression.Parameter(typeof(YourClass), "c");
Expression property = Expression.PropertyOrField(parameter, "Property");
Expression<Func<YourClass, PropertyType>> lamda = Expression.Lambda<Func<YourClass, PropertyType>>(property, parameter);
于 2012-07-20T18:24:57.700 回答