title: C# LINQ to Entities does not recognize the method
body: <p>I'm trying to write a function that sorts by column name       </p>
  
  <p>I have a problem in the second case  case = "Count". How can I convert convert IQueryable to IOrderedQueryable.</p>
  
  <p>Thank You</p>
  
  <pre><code> public PagedResults&lt;activity&gt; getList(Expression&lt;Func&lt;activity, bool&gt;&gt; criteria, PagingSpecification paging)
      {
          IQueryable&lt;activity&gt; search = criteria != null? Query.Where(criteria): Query;
  
          IOrderedQueryable&lt;activity&gt; orderedQuery;
  
          switch (paging.SortColumnName)
          {=
              case "Name":
                  orderedQuery = (paging.SortDirection == SortDirection.Ascending)
                                     ? search.OrderBy(e =&gt; e.Person.Name)
                                     : search.OrderByDescending(e =&gt; e.Person.Name);
                  break;
              case "Count":
                  orderedQuery = (paging.SortDirection == SortDirection.Ascending)
                                       ? search.ToList().OrderBy(e =&gt; e.GetCount()).AsQueryable&lt;activity&gt;()
                                       : search.ToList().OrderByDescending(e =&gt; e.GetCount()).AsQueryable&lt;activity&gt;();
                  break;
              default:
                  orderedQuery = GetOrderedQueryable(search, paging.SortColumnName, paging.SortDirection);
                  break;
          }
  
          IQueryable&lt;activity&gt; dataQuery = orderedQuery.Skip(paging.StartIndex).Take(paging.PageSize);
  
          return new PagedResults&lt;activity&gt;(dataQuery.ToList(), search.LongCount());
      }
  </code></pre>