As already mentioned, if you want to have some kind of custom loading of navigation properties (like filtering or ordering), you can't use the built-in explicit search / delayed loading methods (like Load). Since you are using POCOs, you have only two options:
Filtered projection with anonymous types:
var album = context.Albums.Where(a => a.AlbumId == 1).Select(a => new { a, Photos = a.Photos.OrderByDescending(alb => alb.CreateDate).Take(10) });
This will result in an anonymous type, which may not always be desirable, in this case there is another way:
Two tracked requests:
Album album = context.Albums.Where(a => a.AlbumId == 1).Single(); List<Photo> photos = context.Photos .Where(p => p.AlbumId == 1) .OrderByDescending(a => a.CreateDate).Take(10) .ToList(); foreach (Photo photo in photos) { album.Photos.Add(photo); }
source share