其他分享
首页 > 其他分享> > Linq多集合连接

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 );
        }
    }

  

标签:Name,list1,List,Linq,Add,Age1,集合,new,连接
来源: https://www.cnblogs.com/SHa-Jazy/p/15411342.html