I have a two different Datatables
datatable1: customer, product, shippedqty
datatable2: customer, product, febforecast, marforecast, aprforecast
Here Customer and product columns are same
I need to compare datatable1
with datatable2
on customer
and products
columns and i need to get the result set into new datatable
as
customer,product,dhipedqty,febforecast,marforecast,aprforecast
This is what i've tried:
var tablesJoinend = from t1 in dt.Rows.Cast<DataRow>()
join t2 in forecastdatatable.Rows.Cast<DataRow>()
on new { A = t1["Customer"].ToString(), B = t1["ProductCode"].ToString() }
equals new { A = t2["customer"].ToString(), B = t2["NDC"].ToString() }
select t1;
Now i have tried this which it was not worked
var results = from t1 in dt.Rows.Cast<DataRow>()
join t2 in forecastdatatable.Rows.Cast<DataRow>() on new { A = t1["Customer"].ToString(), B = t1["ProductCode"].ToString() } equals new { A = t2["customer"].ToString(), B = t2["NDC"].ToString() }
select new
{
CustID = Convert.ToInt32(t1["Customer"]),
ColX = Convert.ToInt32(t1["ProductCode"]),
ColY = Convert.ToInt32(t1[3]),
a = Convert.ToInt32(t1[4]),
xx = Convert.ToInt32(t2[4]),
qq = Convert.ToInt32(t2[5])
};