EF6 core – load grandchildren in query – the key is ThenLoad

Working with entity: Tournament

Which has children: TRound with Course as entity that needs to be loaded based on Id ( as each golf round is played on a Course 🙂 )

ctx.Tournaments.Include(c => c.Trounds).ThenInclude(c => c.Course)

Took me a while to figure out why ctx.Tournaments.Include(c => c.Trounds.Select(c => c.Course)) stopped working, but it is a (good) core thingy.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s