Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mutilevel include in C# Linq

I want to have MULTILEVEL include in my linq statment, something like

var a = departments.include(u=>u.Customers)
                   .include(u=>u.Customers.Include(u=>u.Orders);

How should i do that?

Thanks

like image 987
Manvinder Avatar asked Nov 29 '22 03:11

Manvinder


1 Answers

You of course can use lambda expression but you must use special format:

var a = departments.Include(d => d.Customers.Select(c => c.Orders));
like image 192
Ladislav Mrnka Avatar answered Dec 17 '22 19:12

Ladislav Mrnka