title: Order by not-selected column
body: <p>I'm trying to use the SQL operator <code>CONTAINSTABLE</code> to get a list of search results, like this:</p>
  
  <pre><code>SELECT c.*, ccontains.[RANK]
  FROM Customers c
  INNER JOIN CONTAINSTABLE(Customers, LastName, @searchTerm) ccontains ON c.Id = ccontains.[KEY]
  </code></pre>
  
  <p>And calling this function from EF Core 2.1:</p>
  
  <pre><code>var query = DbContext.Customers.FromSql("SELECT * FROM udfSearchCustomers(@searchTerm)",
      new SqlParameter(@searchTerm, mySearchTerm));
  query = query.Include(c =&gt; c.Addresses).Take(maxResults);
  </code></pre>
  
  <p>I want to order my search results descending by <code>RANK</code>, to get the most relevant results at the top. Adding an <code>ORDER BY ccontains.[RANK]</code> to my function is not allowed, as my <code>SELECT * FROM udfSearchCustomers(...)</code> will be wrapped by EF Core: <code>ORDER BY</code> is not allowed on an inner query. Adding <code>query.OrderBy(c =&gt; c.Rank)</code> is not possible, as <code>RANK</code> is not on the <code>Customer</code> entity.</p>
  
  <p>I've tried using <code>System.Linq.Dynamic</code>, as well as other reflection solutions, to do this:</p>
  
  <pre><code>query = query.OrderBy("Rank");
  </code></pre>
  
  <p>But I got an exception: </p>
  
  <blockquote>
    <p>"Rank" is not a member of type "Customer"</p>
  </blockquote>
  
  <p>which is true. Is there any way to order on a column not on an entity, or will I need to create a <code>MyCustomerSearchQuery</code> query object and use AutoMapper to convert those to <code>Customer</code>? I'd rather not, as <code>Customer</code> has many properties and keeping those in sync will be a hassle.</p>
  
  <p>Thanks in advance!</p>