Linq right join

left join就把左边的表放在前面,right join就把右边的表放在前面

 1 var temp = from c in dtcopy.AsEnumerable()
 2                         where !Equals(c.Field<int?>("ParentId"), null)
 3                         select c;
 4             var rightjoin = from r in temp
 5                             join s in (from c in dt.AsEnumerable()
 6                                        select new { DataTagId = c.Field<int>("DataTagId") })
 7                             on r.Field<int?>("ParentId") equals s.DataTagId
 8                             into j
 9                             from jr in j.DefaultIfEmpty()
10                             select new
11                             {
12                                 NullDataTagId = jr != null ? jr.DataTagId : 0,
13                                 row = r
14                             };

 

posted on 2017-01-09 16:12  Riusmary  阅读(159)  评论(0编辑  收藏  举报

导航