Explicit loading of grandchild collections in EF 4.1

后端 未结 1 776
难免孤独
难免孤独 2021-02-07 02:07

Given the following model ...

public class Parent
{
    public int Id { get; set; }
    public ICollection Children { get; set; }
}

public class Ch         


        
1条回答
  •  盖世英雄少女心
    2021-02-07 02:43

    As I pointed in the comment you can try to get query for relation first, then add includes and execute loading. Something like:

    context.Entry(parent)
           .Collection(p => p.Children)
           .Query()
           .Include(c => c.Grandchildren) // I'm not sure if you can include grandchild directly  
           .Load();
    

    0 讨论(0)
提交回复
热议问题