The internal connection in linq to SQL combines two tables according to the public key value. This is represented by the Join operator with an ON clause.
Example:
Suppose we have a database, which contains two tables: dealer and dealerContact. To perform internal connections between these two tables, we will use the following Linq to SQL statements:
This statement retrieves all records that match the dealerid in the dealerContact table in the Dealer table.
var dealercontacts = from contact in DealerContact join dealer in Dealer on contact.DealerId equals dealer.ID select contact;
The conventional syntax connected in the inner connection in linq to SQL is:
Among them: <<>T1 and T2 are tables to be connected
from t1 in db.Table1 join t2 in db.Table2 on t1.field equals t2.field select new { t1.field2, t2.field3}
Field is the public key value
The above is the detailed content of How to Perform an Inner Join in LINQ to SQL?. For more information, please follow other related articles on the PHP Chinese website!