Linq多集合连接

  class Program
    {
        static void Main(string[] args)
        {
            List<Test1> list1 = new List<Test1>();
            List<Test2> list2 = new List<Test2>();
            List<Test3> list3 = new List<Test3>();

            list1.Add(new Test1()
            {
                 Age1 = 30,
                  Name = "30Name"
            });
            list1.Add(new Test1()
            {
                Age1 = 40,
                Name = "30Name"
            });

            list2.Add(new Test2()
            {
                Age2 = 30,
                Name = "30Name2"
            });
            list2.Add(new Test2()
            {
                Age2 = 40,
                Name = "30Name2"
            });

            list3.Add(new Test3()
            {
                Age3 = 30,
                Name = "30Name3"
            });
            list3.Add(new Test3()
            {
                Age3 = 40,
                Name = "30Name3"
            });

            var end = (from a in list1
                       join b in list2 on a.Age1 equals b.Age2
                       join cc in list3 on a.Age1 equals cc.Age3
                       select new Test3()
                       {
                           Age3 = a.Age1,
                           Name1 = a.Name,
                           Name2 = b.Name,
                           Name3 = cc.Name,

                       }).ToList();
            Console.WriteLine( 0 );
        }
    }

  

上一篇:安装与卸载JDK


下一篇:极客时间--DDD实战:如何用DDD重构中台业务模型 笔记