When using Linq to SQL, understanding the syntax of the internal connection is important for query and combination of data from multiple tables. Internal connections allow you to retrieve data that meets the specific conditions of cross -table.
Grammar Overview:
The basic syntax connected to the linq to sql in the ON clause in C#is as follows:
Let's break down the grammar:
from t1 in db.Table1 join t2 in db.Table2 on t1.field equals t2.field select new {t1.field2, t2.field3}
<键> Keywords: initialization query.
from
t1
<指>: Instructions will be executed internal connection. t2
in db.Table1
<定>: Define the connection conditions to equate the specific fields in the two tables. join
db.Table2
on
select
are the tables to be connected. <<> and
are fields used to connect conditions.<句> The statement retrieval of dealers (
var dealercontacts = from contact in DealerContact join dealer in Dealer on contact.DealerId equals dealer.ID select contact;
The above is the detailed content of How to Perform Inner Joins Using LINQ to SQL?. For more information, please follow other related articles on the PHP Chinese website!