Home/ASP.NET Forums/Data Access/ADO.NET, Entity Framework, LINQ to SQL, NHibernate/LINQ-to-SQL: How do you join more than 2 tables?

LINQ-to-SQL: How do you join more than 2 tables? [Answered]RSS

4 replies

Last post Sep 13, 2010 05:54 AM by TippingMonkey

Please mark the replies as answers if they help or unmark if not.

If you have any feedback about my replies, please contact msdnmg@microsoft.com

Microsoft One Code Framework
  • TippingMonkey

    TippingMonke...

    Member

    12 Points

    61 Posts

    Re: LINQ-to-SQL: How do you join more than 2 tables?

    Sep 13, 2010 05:54 AM|TippingMonkey|LINK

    Thank you both, I found out what I am doing wrong. Turns out the argument on the left of the "equals" operator needs to be a reference to a table used before. For example:

    form a in db.TableA
    join  b in d.bTableB on a.ID equals b.ID
    join c in db.TableC on c.CID equals a.CID ...    <===== Is INCORRECT, where:

     

    form a in db.TableA
    join  b in d.bTableB on a.ID equals b.ID
    join c in db.TableC on a.CID equals c.CID ...    <===== Is CORRECT

    Many thanks to your help!
    - K.

    Tipping Monkey - Collective Intelligence for the Stock Market
    http://www.tippingmonkey.com
  • ‹ Previous Thread|Next Thread ›