给定这样的类结构:
public class GrandParent
{
public Parent Parent { get; set;}
}
public class Parent
{
public Child Child { get; set;}
}
public class Child
{
public string Name { get; set;}
}
和以下方法签名:
Expression<Func<TOuter, TInner>> Combine (Expression<Func<TOuter, TMiddle>>> first, Expression<Func<TMiddle, TInner>> second);
我如何实现上述方法,以便可以这样调用它:
Expression<Func<GrandParent, Parent>>> myFirst = gp => gp.Parent;
Expression<Func<Parent, string>> mySecond = p => p.Child.Name;
Expression<Func<GrandParent, string>> output = Combine(myFirst, mySecond);
这样输出结果如下:
gp => gp.Parent.Child.Name
这可能吗?
每个Func的内容只会是一个MemberAccess。我不想最终output成为嵌套函数调用。
谢谢
温温酱
相关分类