join clause

join keyword defined as
join-clause ::= join itemName in srcExpr on keyExpr equals keyExpr
(into itemName)?
Let's select all department's names and managers of department. join clause is used to combine 3 tables with many-to-many relationship.
var result =
    from dep in emp.Departments
    join dm in emp.DEPtManager on dep.DEPtNo equals dm.DEPtNo
    join chef in emp.Employees on dm.EmPNo equals chef.EmPNo
    select new { dep.DEPtName, chef.LastName };

foreach (var a in result)
    Console.WriteLine(a);

Listing 3.

In our case relationships are defined using parent/child lists and query can be simplified. The DataContext hides details of implementation.
var result =
    from dep in emp.Departments
    from dm in dep.DEPtManager
    select new { dep.DEPtName, dm.Employees.LastName };

foreach (var a in result)
    Console.WriteLine(a);

Listing 4.

Result will be the same: Listing4_Output

No comments:

HOWTO: Repair Logitech M325 Mouse

FixIt says that you will find single screw under CE label. It isn't always true.