Take the 2-minute tour ×  What's the most efficient way to
select multiple entities by primary key?  public
IEnumerable<Models.Image> GetImagesById(IEnumerable<int> ids)
//return ids.Select(id => Images.Find(id));       //is this
cool?     return Images.Where( im => ids.Contains(im.Id));  //is
this better, worse or the same?     //is there a (better) third
way?   I realise that I could do some performance tests to
compare, but I am wondering if there is in fact a better way
than both, and am looking for some enlightenment on what the
difference between these two queries is, if any, once they have
been 'translated'.  share|improve this question Well, thats
indeterminate, usually not a huge number, but would like to be
able to support large numbers in a scalable fashion. –  Tom Nov
12 '11 at 22:25 add comment  2 Answers  up vote 46 down vote
accepted  Using Contains in Entity Framework is actually very
slow. It's true that it translates into an IN clause in SQL and
that the SQL query itself is executed fas