patterncsharpCritical
What is the syntax for an inner join in LINQ to SQL?
Viewed 0 times
linqsqlsyntaxinnertheforjoinwhat
Problem
I'm writing a LINQ to SQL statement, and I'm after the standard syntax for a normal inner join with an
How do you represent the following in LINQ to SQL:
ON clause in C#.How do you represent the following in LINQ to SQL:
select DealerContact.*
from Dealer
inner join DealerContact on Dealer.DealerID = DealerContact.DealerIDSolution
It goes something like:
It would be nice to have sensible names and fields for your tables for a better example. :)
Update
I think for your query this might be more appropriate:
Since you are looking for the contacts, not the dealers.
from t1 in db.Table1
join t2 in db.Table2 on t1.field equals t2.field
select new { t1.field2, t2.field3}It would be nice to have sensible names and fields for your tables for a better example. :)
Update
I think for your query this might be more appropriate:
var dealercontacts = from contact in DealerContact
join dealer in Dealer on contact.DealerId equals dealer.ID
select contact;Since you are looking for the contacts, not the dealers.
Code Snippets
from t1 in db.Table1
join t2 in db.Table2 on t1.field equals t2.field
select new { t1.field2, t2.field3}var dealercontacts = from contact in DealerContact
join dealer in Dealer on contact.DealerId equals dealer.ID
select contact;Context
Stack Overflow Q#37324, score: 624
Revisions (0)
No revisions yet.