LINQ to SQL with multiple tables and multiple column join

I have three datatables

dt1
dt2
dt3

dt1 has three columns ID, Date, Price
dt2 has two columns ID, CurrencyCode,
dt3 has three columns CurrencyCode , Date , Rate

I need to join the three tables

                                                      from dataRows1 in dt1.AsEnumerable()
                                     join dataRows2 in dt2.AsEnumerable()
                                     on dataRows1["ID"] equals dataRows2["ID"]                                
                                     join dataRows3 in dt3.AsEnumerable()
                                                       on dataRows2["CurrencyCode"]  equals dataRows3["CurrencyCode"] AND dataRows1["Date"] equals dataRows1["Date"]
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.

käµfm³d 👽Commented:
The last bit of your query needs to introduce anonymous objects. You do this any time you need a mult-column join. For example:

...
join dataRows3 in dt3.AsEnumerable() on
new { CurrencyCode = dataRows2["CurrencyCode"], Date = dataRows1["Date"] } equals
new { CurrencyCode = dataRows3["CurrencyCode"], Date = dataRows3["Date"] }
...

Open in new window

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
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.