我需要在ThenInclude使用其中
var templatesFields = await _context.Sections
.Include(x => x.Subtitles)
.ThenInclude(r => r.Fields.Where(t=>t.TemplatesFields.TemplateID==TemplateID))
.ThenInclude(r => r.OptionSources)
.ThenInclude(r => r.OptionsSourcesDetails)
.ToListAsync();
你不能使用WHERE条件内Include
或ThenInclude
。你可以做的是:
var templatesFields = await _context.Sections
.Include(x => x.Subtitles)
.ThenInclude(r => r.Fields)
.ThenInclude(r => r.OptionSources)
.ThenInclude(r => r.OptionsSourcesDetails)
.Where(t=>t.Subtitles.Fields.Any(x => x.TemplatesFields.TemplateID==TemplateID))
.ToListAsync();