目前,返回類型是:加盟LINQ兩個列表,並返回合併記錄
「System.Collections.GenericList < {A:ConsoleApplication3.Person,B:ConsoleApplication3.Person>
什麼是讓List<Person>
一切就像SQL數據結合將返回的最佳方式 我想只有兩排在List<Person>
:
{Name:Jon, Address=loc1,Country=US,Continent=NA}
{Name:Ryan, Address=loc2,Country=Germany,Continent=Europe}
Person person1 = new Person();
person1.Name = "Jon";
person1.Address = "loc1";
Person person2 = new Person();
person2.Name = "Ryan";
person2.Address = "loc2";
Person person3 = new Person();
person3.Name = "Jon";
person3.Country = "US";
person3.Continent = "NA";
Person person4 = new Person();
person4.Name="Ryan";
person4.Country = "Germany";
person4.Continent = "Europe";
list1.Add(person1);
list1.Add(person2);
list2.Add(person3);
list2.Add(person4);
var result = (from a in list1
join b in list2 on a.Name equals b.Name
select new {a,b}).ToList();