var itemandformulas = from i in AttendanceItemList join f in AttendanceFormulaList on i.AttendanceCode equals f.ItemCode into itemandformula from formula in itemandformula.DefaultIfEmpty() select new { i.IsShouldSpent, i.InUse, i.AttendanceCode, formula, }; foreach (var attenitem in itemandformulas) {
attenitem.formula 为第二个list里的 内容
}
AttendanceItemList left join AttendanceItemList on i.AttendanceCode =f.ItemCode into itemandformula
join 链接
foreach (var update in AttendanceItemList.Join(AttendanceFormulaList, (l) => { return l.AttenceCode; }, (e) => { return e.ItemCode; }, (l, e) => new { l, e })) { }
可以下载一个 linqpad学习一下.
http://www.cnblogs.com/Mayvar/archive/2011/07/04/wanghonghua_201107040534.html