I'm trying to figure out if it is at all possible to combine 2 LambdaExpressions, where one lambda expression uses a Child property of the first.
Given the following 2 classes:
class MyClass
{
public string Name { get; set; }
public SubClass Child { get; set; }
}
class SubClass
{
public string SubClassName { get; set; }
}
And the following expressions:
Expression<Func<MyClass, bool>> Expression1 = c => c.Name == "Test";
Expression<Func<SubClass, bool>> Expression2 = sc => sc.SubClassName == "SubTest";
I'd like to combine it to a lambda of the following type:
Expression<Func<MyClass, bool>> Combined;
Reason being: The upper lambda is internal, and the lower lamba would be passed in by the 'user' of the method, which has no idea (nor should he) that MyClass exists, has only knowledge of SubClass.
Is this at all possible, or should I find another road to follow?