I am trying to combine expr1 and expr2 to produce an Expression<Func<float>>:
var expr1 = (Expression<Func<ColorComponent>>)(() => _modelRgb.R);
var expr2 = (Expression<Func<ColorComponent, float>>)(s => s.Value);
var expr3 = Expression.Lambda(expr1, expr2.Parameters);
While the call to expr3 does work, its .Body property cannot be casted as MemberExpression.
Here are the debug strings of a manually crafted expression and expr3, obviously they're different:
"() => (ColorPicker.ColorPickerWindow2)._modelRgb.R.Value"
"s => () => (ColorPicker.ColorPickerWindow2)._modelRgb.R"
The question is:
What is the correct way to make expr3 a MemberExpression instead of a LambdaExpression ?
What I'm trying to achieve:
I'd like to pass expressions like () => _modelRgb.R that points to a ColorComponent to a method, and in this method I'd like to build numerous expression to some of its members.