1.代码
//group join var groupJoinQS = from addr in Address.GetAddress() join emp in Employee.GetAllEmployees() on addr.ID equals emp.AddressId into ADDEmp select new { addr, ADDEmp }; foreach (var item in groupJoinQS) { Console.WriteLine(item.addr); Console.WriteLine(item.ADDEmp); Console.WriteLine(item.addr.AddressLine); foreach (var employee in item.ADDEmp) { Console.WriteLine(" EmployeeID : " + employee.ID + " , Name : " + employee.Name); } }
2.测试结果如下
所以ADDEmp指的是Employee?
参考:
https://dotnettutorials.net/lesson/linq-group-join/