title: Order column by a separate `List<string>` variable
body: <p>I need to sort the results of an entity framework query by the index of elements in another list.</p>
  
  <p>I tried the suggestion found elsewhere, like </p>
  
  <pre><code>.ThenBy(m=&gt;list.IndexOf(m.Term))
  </code></pre>
  
  <p>but I get an HTTP 500 error, so I'm wondering if I'm missing something. When debugging, I get this inner exception.  </p>
  
  <blockquote>
    <p>LINQ to Entities does not recognize the method 'Int32
    IndexOf(System.String)' method, and this method cannot be translated
    into a store expression.</p>
  </blockquote>
  
  <p>In particular, I'm thinking of this scenario. </p>
  
  <pre><code>private IEnumerable&lt;MiaLog1A&gt; PopulateQuery(string selectedCampus)
  {
      var list = new List&lt;string&gt; {"No Longer Alphabetical","Fall","Mid","Spring"};
      return _db.MiaLog1A.Where(m =&gt; m.Campus == selectedCampus)
              .OrderBy(m =&gt; m.StudentName)
              .ThenBy(m=&gt;m.Term)  
                      /* I would like to sort "Term" by the 
                       * order of "list".
                       */
          .AsEnumerable();
  }
  </code></pre>
  
  <p>Is there a way I could sort in this manner, or am I restricted to ordering by a dictionary or creating a join?</p>