Is it possible in EF to include 4th level and maybe even deeper?
What i've tried:
var anime = AnimeTimeDbContext.Animes
.Include(a => a.Images.Select(ai => ai.Image.Thumbnails))
And:
var anime = AnimeTimeDbContext.Animes
.Include(a => a.Images.Select(ai => ai.Image).Select(i => i.Thumbnails))
But without success.
I know that in EF Core we can use .ThenInclude, but i can't switch atm.
CodePudding user response:
EF6 supports including multiple levels, it's just a bit more clumsy than EF Core. Give this a try:
var anime = AnimeTimeDbContext.Animes
.Include(a => a.Images)
.Include(a => a.Images.Select(i => i.Thumbnails));
The first Include includes the Images, the second tells EF to include the Thumbnails for each image.