Questions tagged «eager-loading»

7
实体框架-包含多个级别的属性
Include()方法对于对象列表非常有效。但是,如果我需要深入两个层次怎么办?例如,下面的方法将返回具有此处显示的包含属性的ApplicationServers。但是,ApplicationsWithOverrideGroup是另一个包含其他复杂对象的容器。我也可以在该属性上执行Include()吗?或如何才能完全加载该属性? 就目前而言,此方法: public IEnumerable<ApplicationServer> GetAll() { return this.Database.ApplicationServers .Include(x => x.ApplicationsWithOverrideGroup) .Include(x => x.ApplicationWithGroupToForceInstallList) .Include(x => x.CustomVariableGroups) .ToList(); } 将仅填充Enabled属性(在下面),而不填充Application或CustomVariableGroup属性(在下面)。我如何做到这一点? public class ApplicationWithOverrideVariableGroup : EntityBase { public bool Enabled { get; set; } public Application Application { get; set; } public CustomVariableGroup CustomVariableGroup { get; set; } }

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.