I am trying to return a List<Image> but am having trouble with the following method:
public List<Image> GetImageByCollection(int id) { List<Image> images = collectionDb.Images.SelectMany(i => i.CollectionId == id); return images; } I am new to Linq so its probably something basic but hopefully you can see what I am trying to do. If I am not clear please say and I will try to clarify.
SelectManygenerates anIEnumerable<>from each element in the source sequence, then concatenates all of those sequences into a single sequence. (For example, if you have a sequence of client representatives, and you want to get a sequence of all clients served by those representatives, SelectMany would do the job.) That doesn't seem to be your goal here. Assuming you're trying to filter your list for those whoseCollectionIdmatchesid, Joe Tuskan's answer is correct.