My domain model is:
Book
public class Book
{
public int Id { get; set; }
public string Name { get; set; }
public int ReleaseYear { get; set; }
public virtual ICollection<Store> Stores { get; set; }
}
Store
public class Store
{
public int Id { get; set; }
public string Name { get; set; }
public int BookId { get; set; }
public virtual Book Book { get; set; }
public virtual ICollection<StoreLocation> Locations { get; set; }
}
StoreLocation
public class StoreLocation
{
public int Id { get; set; }
public string Address { get; set; }
public int StoreId { get; set; }
public virtual Store Store { get; set; }
}
How can include all the levels (and sublevels) of a Book?
public Book GetBookById(int Id)
{
return this._DbContext.Books
.Include(p => p.Stores)
.FirstOrDefault(p => p.Id == Id);
}
What i tried?
.ThenInclude(p => p.StoreLocation)doesn't work.
Listin anotherListi cannot include the second one.