For a model like below
public class Parent
{
public int Id { get; set; }
public List<Child> Children { get; set; }
}
public class Child
{
public int ChildId { get; set; }
public int ParentId { get; set; }
public List<Child> GrandChildren { get; set; }
}
public class GrandChild
{
public int GrandChildId { get; set; }
public int ChildId { get; set; }
}
How do I write a query that gets all the Children and GrandChildren in the Include/ThenInclude statements?
var record = GetAll()
.Where(r => r.Id == 4)
.Include(r => r.Children)
.ThenInclude(????????????)
In the "ThenInclude" statement, I cannot use a select statement to get the grandchildren. What will be the right way to get the GrandChildren collection?
Much appreciated.