title: Why can't I convert Expression Body to MethodCallExpression
body: <p>Given the following class:</p>
  
  <pre><code>public class MyClass {
  
      private readonly UrlHelper _urlHelper;
  
      // constructor left out for brevity
  
      // this is one of many overloaded methods
      public ILinkableAction ForController&lt;TController, T1, T2&gt;(Expression&lt;Func&lt;TController, Func&lt;T1, T2&gt;&gt;&gt; expression) {
          return ForControllerImplementation(expression);
      }
  
      private ILinkableAction ForControllerImplementation&lt;TController, TDelegate&gt;(Expression&lt;Func&lt;TController, TDelegate&gt;&gt; expression) {
          var linkableMethod = new LinkableAction(_urlHelper);
  
          var method = ((MethodCallExpression) expression.Body).Method;
          method.GetParameters().ToList().ForEach(p =&gt; linkableMethod.parameters.Add(new Parameter {
              name = p.Name,
              parameterInfo = p
          }));
  
          return linkableMethod;
      }
  }
  </code></pre>
  
  <p>and the following implementation:</p>
  
  <pre><code>var myClass = new MyClass(urlHelper);
  myClass.ForController&lt;EventsController, int, IEnumerable&lt;EventDto&gt;&gt;(c =&gt; c.GetEventsById);
  </code></pre>
  
  <p>where <code>GetEventsById</code> has the signature:</p>
  
  <pre><code>IEnumerable&lt;EventDto&gt; GetEventsById(int id);
  </code></pre>
  
  <p>I'm getting the error:</p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.Linq.Expressions.UnaryExpression' to type 'System.Linq.Expressions.MethodCallExpression'.</p>
  </blockquote>
  
  <ol>
  <li>How can I convert the expression to the appropriate type to get the <code>MethodInfo</code> of the given expression?</li>
  <li><code>TDelegate</code>, in the above example, is <code>Func&lt;int, IEnumerable&lt;EventDto&gt;&gt;</code> at runtime. So being that it's a <code>Delegate</code> why am I not able to get the <code>MethodInfo</code> from the expression?</li>
  </ol>