title: Combining two lambda expressions in c#
body: <p>Given a class structure like this:</p>
  
  <pre><code>public class GrandParent
  {
      public Parent Parent { get; set;}
  }
  public class Parent
  {
      public Child Child { get; set;}
  }
  
  public class Child
  {
      public string Name { get; set;}
  }
  </code></pre>
  
  <p>and the following method signature:</p>
  
  <pre><code>Expression&lt;Func&lt;TOuter, TInner&gt;&gt; Combine (Expression&lt;Func&lt;TOuter, TMiddle&gt;&gt;&gt; first, Expression&lt;Func&lt;TMiddle, TInner&gt;&gt; second);
  </code></pre>
  
  <p>How can I implement said method so that I can call it like this:</p>
  
  <pre><code>Expression&lt;Func&lt;GrandParent, Parent&gt;&gt;&gt; myFirst = gp =&gt; gp.Parent;
  Expression&lt;Func&lt;Parent, string&gt;&gt; mySecond = p =&gt; p.Child.Name;
  
  Expression&lt;Func&lt;GrandParent, string&gt;&gt; output = Combine(myFirst, mySecond);
  </code></pre>
  
  <p>such that output ends up as:</p>
  
  <pre><code>gp =&gt; gp.Parent.Child.Name
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p>The contents of each Func will only ever be a <code>MemberAccess</code>. I'd rather not end up with <code>output</code> being a nested function call.</p>
  
  <p>Thanks</p>