Ray*_*yan 3 linq api entity-framework .net-core asp.net-core
我需要在 ThenInclude 中使用 where
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();
Run Code Online (Sandbox Code Playgroud)
Der*_*ğlu 12
您不能在Include
或 中使用 where 条件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();
Run Code Online (Sandbox Code Playgroud)
编辑:这可以通过 .Net Core 5.0(现在处于预览状态)
var blogs = context.Blogs
.Include(e => e.Posts.Where(p => p.Title.Contains("Cheese")))
.ToList();
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5466 次 |
最近记录: |