title: Linq Where Contains ... Keep default order
body: <p>I have a collection of ID numbers that I wish to return some object for, I'm doing it by using a linq statement with a where that's using a contains statement:</p>
  
  <pre><code>var recentCats = (from i in EntityCache.Default.GetAll&lt;Categories&gt;()
                            where WebProfile.Current.RecentlyCreatedCategories.Contains(i.Id)
                            &amp;&amp; BoundCategory.ParentItemClass.Id.Equals(i.ParentItemClass.Id)
                            select new CategoryInfo()
                            {
                                Category = i,
                                ClassId = i.ParentItemClass.Id,
                                ClassImage = NamedResourceManager.GetResourceBinary(i.ParentItemClass.NameResourceId)
                            });
  </code></pre>
  
  <p>This works perfectly fine, except that I want to keep the order of items in the returned collection the same as they were in the list that goes in.  So for example if I had a list of IDs: 14, 603, 388, I want the objects that come back to be in the same order, not the order that they're returned by the cache.  Is there any way in entity framework to do this, or any way to do it that doesn't involve me writing a foreach loop?</p>
  
  <p>Thanks</p>