linq左连接

   Table1和Table2连接,把Table1的全列出来
         var tempData = from a in table1
                           join b  in table2
                           on a.Id equals b.aId
                           into TempTable
                           from temp in TempTable.DefaultIfEmpty()
                           select new
                           {
                               Program = a.UnitOfBusiness,
                               Tier = a.Tier,
                               Market = a.Market,
                               Id = a.Id,
                               CRM = temo.CRM,//表2的内容
                               RMShipId =temp.Id    //表2的内容
                          };
temp里面的字段就是b(table2)的字段,select表2的字段就要temp点字段,不能用b点字段,b点不来任何字段

 

posted @ 2015-03-31 15:27  小姐,请叫我“序员”好吗  阅读(157)  评论(0编辑  收藏  举报