multiple table connection queries are often used in queries about databases, where the query functionality for LINQ is simply presented. 1, single-table query [CSharp] View plain copyvarquery = fromTcinchDb.tbclasswhereTc. ClassID = ="1" //query Form Tbclass Select New{ClassID=TC. ClassID, ClassName=TC. ClassName}2, multi-table connection query [CSharp] View plain copyvarquery = fromSinchdb.tbstudents join Cinchdb.tbclass on S.classid equals C.classidwhereS.classid = =3 Select New{ClassID=S.classid, ClassName=C.classname, Student=New{Name=S.name, StudentID=S.studentid}}; The inner join, like the inner join in SQL, finds the intersection of two sequences. 3, outer connection [CSharp] View plain copyvarquery = fromSinchdb.tbstudents join Cinchdb.tbclass on S.classid equals c.classid to TbC fromTbcwinchTbc.defaultifempty ()whereS.classid = =3 Select New{ClassID=S.classid, ClassName=Tbcw.classname, Student=New{Name=S.name, StudentID=S.studentid}}; Note that when connecting to an external table, the from add-in will need to be into a new variable and then call the DefaultIfEmpty () method.
Linq to SQL Table query (GO)