I'm writing a LINQ to SQL statement, and I'm after the standard syntax for a normal inner join with an 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.DealerID
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.
And because I prefer the expression chain syntax, here is how you do it with that:
One Best example
Table Names :
TBL_Emp
andTBL_Dep
try instead this,
Write table names you want, and initialize the select to get the result of fields.
basically LINQ join operator provides no benefit for SQL. I.e. the following query
will result in INNER JOIN in SQL
join is useful for IEnumerable<> because it is more efficient:
clause would be re-executed for every dealer But for IQueryable<> it is not the case. Also join is less flexible.