欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

LINQ 多条件join on

程序员文章站 2022-03-16 23:43:15
var tmp = from a in DT1.AsEnumerable() join b in DT2.AsEnumerable() on new { bm = a.Field("编码"), lx = "类型" } equals new { bm = b.Field ......

var  tmp = from a in dt1.asenumerable()
join b in dt2.asenumerable()
on new { bm = a.field<string>("编码"), lx = "类型" } equals new { bm = b.field<string>("编码"), lx = b.field<string>("类型") }
into ab
from c in ab.defaultifempty()
select new
{
编码 = a.field<string>("编码"),
类型 = c == null ? "" : c.field<string>("类型")
};
dt_结果 = tmp.mycopytodatatable();