title: 'Invoke' node is not supported in LINQ when nesting Expression Functions
body: <p>I am trying to nest <code>Expression Functions</code>, I've tried multiple things (<code>Invoke</code>, <code>Compile</code> etc.) and read topics about this exception, but did not see any case appending when nesting expression functions. I don't know much about it, it is pretty new for me, I guess I must have missed something very simple.<br>
  My aim is just to be able to nest expressions so that <code>GetAbilities</code> could be used in multiple other expressions without having to duplicate its code.</p>
  
  <p>How could I achieve such a thing ?</p>
  
  <pre><code>public static Expression&lt;Func&lt;User, bool&gt;&gt; Test
      {
          get
          {
              Expression&lt;Func&lt;User, bool&gt;&gt; res = (u =&gt; GetAbilities.Compile()(u).Any());
              return res;
          }
      }
  
      public static Expression&lt;Func&lt;User, IEnumerable&lt;Ability&gt;&gt;&gt; GetAbilities
      {
          get
          {
              Expression&lt;Func&lt;User, IEnumerable&lt;Ability&gt;&gt;&gt; res = u =&gt; u.AllAbilities.Where(a =&gt; a.Type == Ability.TypeE.Initial);
              return res;
          }
      }
  </code></pre>
  
  <p>In the above example, when retrieving the results of <code>Test</code> I got the follwing exception :</p>
  
  <blockquote>
    <p>The LINQ expression node type 'Invoke' is not supported in LINQ to Entities.</p>
  </blockquote>
  
  <p><strong><em>UPDATE</em></strong></p>
  
  <p>See working accepted solution below :)<br>
  Since this is now working, would anybody know what should be done about those unmapped properties ? Concretly, the <code>GetAbilities</code> method refers to another another one in <code>User</code> class, but I can't use it directly in queries since this is an unmapped method. So the question is should I leave the <code>Abilities</code> property in <code>User</code> class for internal use and static <code>GetAbilities</code> for queries purpose (but this is duplicating code in a way), or may be compile and invoke the static <code>GetAbilities</code> in the <code>User</code> class ?</p>
  
  <p>Leave it as is it does not seems very clean and maintainable (seems quite simple here but real functions are more complex):</p>
  
  <pre><code>// Used for queries
  public static Expression&lt;Func&lt;User, IEnumerable&lt;Ability&gt;&gt;&gt; GetAbilities
  {
      get
      {
          Expression&lt;Func&lt;User, IEnumerable&lt;Ability&gt;&gt;&gt; res = u =&gt; u.AllAbilities.Where(a =&gt; a.Type == Ability.TypeE.Initial);
          return res;
      }
  }
  
  // Used for internal purpose
  public IEnumerable&lt;Ability&gt; Abilities
  {
      get
      {
          return AllAbilities.Where(a =&gt; a.Type == Ability.TypeE.Initial);
      }
  }
  </code></pre>