首页 > 代码库 > Linq 左外连接

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

 

结果

技术分享

 

Linq 左外连接