Linq 左外连接

swip                                      consumer

 

                                   

 

 

 1   var result = from x in swip
 2                      join y in consumer on x.f_CardNO equals y.f_CardNO into data
 3                      from z in data.DefaultIfEmpty()
 4                      select new
 5                        {
 6                                      x.f_RecID,
 7                                      x.f_CardNO,
 8                                      x.f_ControllerSN,
 9                                      x.f_InOut,
10                                      x.f_ReadDate,
11                                      x.f_ReaderID,
12                                      f_ConsumerName=z==null?"":z.f_ConsumerName,
13                                      x.f_RecordFlashLoc,
14                                      x.f_ReaderNO,
15                        };

 

结果

 

posted @ 2017-07-27 17:17  XinYiBuFang  阅读(543)  评论(0编辑  收藏  举报