Query for a table of Linq to SQL

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.