countrymeister
asked on
How to update a datatable field in linq to sql with a value from another datatable field
I tried this, but it does not update the values.
dt1.Rows.Cast<DataRow>().J oin(dt2.Ro ws.Cast<Da taRow>(),
r1 => new { p1 = r1["ID"], p2 = r1["Date"] },
r2 => new { p1 = r2["ID"], p2 = r2["Date"] },
(r1, r2) => new { r1, r2 }).ToList()
.ForEach(o => o.r1.SetField("Price", o.r2["Price"]));
dt1.Rows.Cast<DataRow>().J
r1 => new { p1 = r1["ID"], p2 = r1["Date"] },
r2 => new { p1 = r2["ID"], p2 = r2["Date"] },
(r1, r2) => new { r1, r2 }).ToList()
.ForEach(o => o.r1.SetField("Price", o.r2["Price"]));
It looks like you are using a DataTable object and NOT Linq to SQL is that correct?
ASKER
Yes, I have two datatables,
I need to update the values in dt1 if they qualify on the join in dt2
I need to update the values in dt1 if they qualify on the join in dt2
ASKER
Sorry Fernando, I am using LINQ to SQL, nothing to do with database updates.
Just wanted to update certain rows in datatable on certain conditions
Just wanted to update certain rows in datatable on certain conditions
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My fields were not in the correct format, my fault