I have models that look like the following:
public class Note
{
public long? ID { get; set; }
public long AuthorID { get; set; }
public virtual ICollection<Image> Images { get; set; }
...
}
public class Image
{
public long? ID { get; set; }
public byte[] Thumbnail { get; set; }
public byte[] FullRes { get; set; }
}
Which I can load with the following:
List<Note> a = dBContext.Notes.Where(x => x.AuthorID == myId)
.Include(x => x.Images).ToList();
I would however like to avoid loading the FullRes member of Image as it is large. Something along the lines of the following (which throws an ArgumentException - The include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties.):
List<Note> a = dBContext.Notes.Where(x => x.AuthorID == myId)
.Include(x => x.Images.Select(i => new Image
{
ID = i.ID,
Thumbnail = i.Thumbnail
})).ToList();
Does anyone know the correct syntax to achieve this goal?