Entity Framework - Include Multiple Levels of Properties

前端 未结 8 812
囚心锁ツ
囚心锁ツ 2020-11-22 08:43

The Include() method works quite well for Lists on objects. But what if I need to go two levels deep? For example, the method below will return ApplicationServers with the i

8条回答
  •  故里飘歌
    2020-11-22 08:54

    If I understand you correctly you are asking about including nested properties. If so :

    .Include(x => x.ApplicationsWithOverrideGroup.NestedProp)
    

    or

    .Include("ApplicationsWithOverrideGroup.NestedProp")  
    

    or

    .Include($"{nameof(ApplicationsWithOverrideGroup)}.{nameof(NestedProp)}")  
    

提交回复
热议问题