I have a set of identification numbers for which I want to return some object, I do this using the linq statement with where the contains statement is used:
var recentCats = (from i in EntityCache.Default.GetAll<Categories>() where WebProfile.Current.RecentlyCreatedCategories.Contains(i.Id) && BoundCategory.ParentItemClass.Id.Equals(i.ParentItemClass.Id) select new CategoryInfo() { Category = i, ClassId = i.ParentItemClass.Id, ClassImage = NamedResourceManager.GetResourceBinary(i.ParentItemClass.NameResourceId) });
This works fine, except that I want to keep the order of the items in the returned collection the same as in the list that comes in. So, for example, if I had a list of identifiers: 14, 603, 388, I want the objects to be returned in the same order, and not in the order in which they were returned by the cache. Is there a way in the entity infrastructure to do this, or is there any way to do this that doesn't imply that I am writing a foreach loop?
thanks
source share