首页 新闻 会员 周边

linq left join

0
悬赏园豆:20 [已解决问题] 解决于 2013-11-28 13:15
 var a = AttendanceItemList.GroupJoin(
                     AttendanceFormulaList,
                     (i) => i.AttendanceCode,
                     (f) => f.ItemCode,
                     (i, f) => new { i = i, f = f });

                foreach (var attenitem in a)
                {}

我的 目的是 得到  :AttendanceItemList  i  left join AttendanceFormulaList   f on i.AttendanceCode=f.ItemCode 做连接后的结果及  请问我foreach里的代码应该 怎么写呢

或 我整个 这段 代码 该 怎么写呢

梁娜的主页 梁娜 | 初学一级 | 园豆:39
提问于:2013-11-25 14:49
< >
分享
最佳答案
0

你这里的写法为:

var result = from a in AttendanceItemList 
                 join b in AttendanceFormulaList 
                 on  a.AttendanceCode equals b.ItemCode into t 
                 from c in t.DefaultIfEmpty() 
                 select new {
                    a.AttendanceCode,
                    b.ItemCode,
                    //... other colnums
                 } ;       

 

这里介绍了 join, left join 等的写法,你去学习一下

http://www.cnblogs.com/Mayvar/archive/2011/07/04/wanghonghua_201107040534.html

收获园豆:15
袁家小黑球 | 小虾三级 |园豆:1045 | 2013-11-26 09:46
其他回答(1)
0

后边加上selectMany

你下一个linqpad学一下linq吧

AttendanceItemList.GroupJoin(
AttendanceFormulaList,
(i) => i.AttendanceCode,
(f) => f.ItemCode,
(i, f) => new { i = i, f = f }).SelecteMany(........

可以看一下这个帖子

http://www.cnblogs.com/li-peng/p/3441729.html

收获园豆:5
li-peng | 园豆:954 (小虾三级) | 2013-11-25 15:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册