내 도메인 모델은 다음과 같습니다엔티티 프레임 워크 코어를 사용하여 모든 레벨을로드하는 방법
예약
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; }
}
스토어
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
,536,public class StoreLocation
{
public int Id { get; set; }
public string Address { get; set; }
public int StoreId { get; set; }
public virtual Store Store { get; set; }
}
Book
의 모든 레벨 (및 하위 레벨)을 어떻게 포함 할 수 있습니까?
public Book GetBookById(int Id)
{
return this._DbContext.Books
.Include(p => p.Stores)
.FirstOrDefault(p => p.Id == Id);
}
나는 무엇을 시도 했습니까?
.ThenInclude(p => p.StoreLocation)
이 작동하지 않습니다.
[ThenInclude] (https://docs.efproject.net/en/latest/querying/related-data.html#including-multiple-levels)를 사용해 보셨습니까? – tmg
예. 다른 List에'List'가있을 때는 두 번째 것을 포함 할 수 없습니다. –