Loading Nested Entities / Collections with Entity Framework

后端 未结 2 1055
离开以前
离开以前 2020-12-14 19:05

I am trying to Eagerly load all the related entities or collection of Entity in one call. My Entities Looks like:

Class Person
{
    public virtual long Id {         


        
2条回答
  •  悲哀的现实
    2020-12-14 19:29

    You can try this:

    Context.Employees
        .Include(e => e.Person)
        .Include(e => e.Titles.Select(t => t.Title))
        .ToList();
    

    Select can be applied to a collection and loads navigation properties of the next level in the object graph.

提交回复
热议问题