EF. How to include only some sub results in a model?
问题 I'm trying to select list of Users and for each User JobTitle in correct language depended of strLang selected by user. Something like that: IList<User> myData; myData = Context.Users.Where(u => u.Location == strLocation) .Include(u => u.JobTitles.Where(e => e.Language == strLang)) .ToList(); But it seems Include doesn't like Where clause 回答1: You can't conditionally include only a few entities of a related collection, so you should use projection to get the stuff you need: IList<User> myData