我正在尝试在2个数据表上执行左外连接并收到错误:对象引用未设置为对象的实例。 我的代码是:
var result =
from dataRows1 in dtInv.AsEnumerable()
join dataRows2 in dtSal.AsEnumerable()
on dataRows1.Field<string>("taken_by").ToUpper() == null ? "" : dataRows1.Field<string>("taken_by").ToUpper()
equals dataRows2.Field<string>("taken_by").ToUpper() == null ? "" : dataRows2.Field<string>("taken_by").ToUpper() into lj
from r in lj.DefaultIfEmpty()
select dtResult.LoadDataRow(new object[]
{
dataRows1.Field<string>("taken_by") == null ? "": dataRows1.Field<string>("taken_by"),
dataRows1.Field<int>("TotalInv") == null ? 0 : dataRows1.Field<int>("TotalInv"),
dataRows1.Field<double>("TotalAmt") == null ? 0.00 : dataRows1.Field<double>("TotalAmt"),
r == null ? 0 : r.Field<int>("TotalSal"),
r == null ? 0 : r.Field<double>("SalAmt")
}, false);