I'm trying to write an entity framework lambda expression to retrieve the related child data and two related grandchild data from two tables, plus a fourth child table. Here's the relationships.
The parent table is Class. Class has a child table called Course. Course has two child tables, CertificationLevel and CertificationType. The fourth table is called ClassLocation, and is a child table of Class.
I've got to bring in all the related Course, CertificationLevel, CertificationType, and ClassLocation for all the retrieved Class data.
This is what I've currently got:
var recordList = ctx.Classes.OrderByDescending(r => r.ID).Include(c => c.Course).Include(cl => cl.ClassLocation).Take(300);
I searched around for help and found this website Include Multiple Levels, but it doesn't work. Here's the line that I'm having trouble with Include(i => i.Invoices.Select(it => it.Items))
. When I try to modify my lambda expression, the Select
method isn't recognized.
So, what's wrong and how do I correct it?
I'm using EF 6.4.4. We're using .NET 4.5.2