Use Linq to SQL to execute internal connection
Inner connection query
<code class="language-sql">select DealerContact.* from Dealer inner join DealerContact on Dealer.DealerID = DealerContact.DealerID</code>
<code class="language-csharp">var dealerContacts = from contact in DealerContact join dealer in Dealer on contact.DealerId equals dealer.ID select contact;</code>
clauses, specify the source table (dealercontact). from
The clause uses equal conditions on the dealerid field to link the DealerContact table to the Dealer table. Finally, we use clauses to select the required fields (dealercontact.*). join
select
The alternative method of specific query
This allows you to adjust the query flexibly according to the required output.
<code class="language-csharp">var dealers = from dealer in Dealer join contact in DealerContact on dealer.DealerID equals contact.DealerId select dealer;</code>
The above is the detailed content of How to Perform Inner Joins with LINQ to SQL?. For more information, please follow other related articles on the PHP Chinese website!