Link to home
Create AccountLog in
Avatar of VBdotnet2005
VBdotnet2005Flag for United States of America

asked on

join in LINQ to SQL

How do we join two tables in LINQ to SQ?

table_A     table_b

id              id
acct          acct
address    job_position
Avatar of aibusinesssolutions
aibusinesssolutions
Flag of United States of America image

In VB.NET it would be like this.

Dim q = From a In db.table_A _
            Group Join b In db.table_B On a.id Equals b.id Into employees = Group _
            Select New With {a.address, b.job_position}
Avatar of VBdotnet2005

ASKER

Group join kind of like innerjoin?
What is Into employees = Group ?
ASKER CERTIFIED SOLUTION
Avatar of aibusinesssolutions
aibusinesssolutions
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
employees is a temporary object to hold the join, I just named it employees, it can be anything.  

Group Select New With {a.address, b.job_position} creates the group that you can enumerate through
If you want more examples of advanced joins or other LINQ to SQL samples, check this page out.

http://msdn.microsoft.com/en-us/vbasic/bb688085.aspx