Java教程

LINQ:Group Join

本文主要是介绍LINQ:Group Join,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

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/

这篇关于LINQ:Group Join的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!