linq关联a和b,多条件关联关联字段ID,Code
实体tableA的ID为int类型,实体tableB的ID为int?,这样正常写的的话如下:
var obj = from s in Entity.tableA
join b in Entity.tableB on new {a.ID,a.Code} equals new {b.ID,b.Code}
select new{ //此处省略 };
会报类型错误,可以做如下修改就可以实现了
var obj = from s in Entity.tableA
join b in Entity.tableB on new {id=a.ID,a.Code} equals new {id=b.ID.Value,b.Code}
select new{ //此处省略 };