Say I have two classes like the following:
public class A
{
public B B { get; set; }
}
public class B
{
public string SomeValue { get; set; }
}
And the following expressions:
using System.Linq.Expressions;
// Actual expression much more complicated
Expression<Func<B, string>> mainExpression = b => b.SomeValue;
Expression<Func<A, B>> aToB = a => a.B;
How would I combine them? Obviously I could write
Expression<Func<A, string>> newExpression = a => a.B.SomeValue;
But the real "mainExpression
" is much more complicated and I'd like to avoid code duplication.
I'm using EntityFramework, these are classes representing database tables, which is why I need a System.Linq.Expressions.Expression
object.