實體框架-包括多個屬性級別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();}只填充已啟用的屬性(下面),而不填充Application或CustomVariableGroup屬性(如下)。我該怎么做?public class ApplicationWithOverrideVariableGroup : EntityBase{
public bool Enabled { get; set; }
public Application Application { get; set; }
public CustomVariableGroup CustomVariableGroup { get; set; }}
3 回答

慕蓋茨4494581
TA貢獻1850條經驗 獲得超11個贊
.Include(x => x.ApplicationsWithOverrideGroup.NestedProp)
.Include("ApplicationsWithOverrideGroup.NestedProp")
.Include($"{nameof(ApplicationsWithOverrideGroup)}.{nameof(NestedProp)}")
- 3 回答
- 0 關注
- 469 瀏覽
添加回答
舉報
0/150
提交
取消