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>().Join(dt2.Rows.Cast<DataRow>(),
            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"]));
LVL 1
countrymeisterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
It looks like you are using a DataTable object and NOT Linq to SQL is that correct?
0
countrymeisterAuthor Commented:
Yes, I have two datatables,
I need to update the values in dt1 if they qualify on the join in dt2
0
countrymeisterAuthor Commented:
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
0
Fernando SotoRetiredCommented:
I have tested your code and find it to work as expected. The Price column of DataTable 2 updates the Price column of DataTable 1.

What are you looking at when you say it is not working?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
countrymeisterAuthor Commented:
My fields were not in the correct format, my fault
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.