static IEnumerable <Employee> JoinTest() { LinqTest linqTest = new LinqTest(); var result = from l1 in linqTest.list1 join l2 in linqTest.list2 on l1.Name equals l2.Name select l1; return(result); }
static IEnumerable <dynamic> JoinDynamicTest() { LinqTest linqTest = new LinqTest(); var result = from l1 in linqTest.list1 join l2 in linqTest.list2 on l1.Name equals l2.Name select new { l1, l2.Age }; return(result); }
static IEnumerable <dynamic> LeftJoinTest() { LinqTest linqTest = new LinqTest(); var result = from l1 in linqTest.list1 join l2 in linqTest.list2 on l1.Name equals l2.Name into l1l2 from x in l1l2.DefaultIfEmpty() select new { l1, x.Name }; return(result); }
static void Main1(string[] args) { //LinqTest.JoinTest(); LinqTest.JoinDynamicTest(); }