title: Sorting a list of objects by another list of objects VB.NET LINQ
body: <p>So, here's a simplified version of the situation:
  I have Gyms in a database:</p>
  
  <pre><code>Gym: GymID, Name
  GymAmenities: GymID, AmenityID
  Amenities: AmenityID
  </code></pre>
  
  <p>So a Gym, can have 0 to many "Amenities".  Along comes a user who prioritizes amenities that are important to him or her:</p>
  
  <pre><code>UserPrefAmenities: UserID, AmenityID, Ranking
  </code></pre>
  
  <p>Now when searching for a gym in a zip code, I want the search results to be in order of the user preferred amenities in order of rank...</p>
  
  <pre><code>gyms = (From g In db.Gyms Where g.Zip = thisRequest.Zip Order By g.GymAmenitys.Contains(From upa In thisUser.UserPrefAmenitys Order By upa.Rank)).ToList
  </code></pre>
  
  <p>Or something like that...</p>
  
  <p>*note that running the above results in:</p>
  
  <blockquote>
    <p>Unable to create a constant value of type 'UserPrefAmenity'. Only
    primitive types or enumeration types are supported in this context.</p>
  </blockquote>