Basic query of relational data-LinQ, and query by linq

Source: Internet
Author: User

Basic query of relational data-LinQ, and query by linq

As shown in the relational data, the LinQ statement is:

 


Var Query = from a in data. awhere. admin = input username &. pwd = input password (a model entity can be passed in) join B in data. B on. bid equals B. id into AB from r1 in AB. defaultIfEmpty () join c in data. C on r1.cid equals c. id into bc from r2 in bc. defaultIfEmpty () join d in data. D on r2.did equals d. id into cd from r3 in cd. defaultIfEmpty ()

Select new {// the id of table A; Id =. id, // here is the Name of table B; Name = r1.Name, Pro = r2.Pro, IpAdd = r3.IpAdd}; // convert it into an array; var list = Query. toList (); // list [0]. name indicates the Name of table B of the first data in the result of the entire LinQ query, and so on;

 

Note: r1 can output all data of table B... and so on;

R2 = table C;

R3 = table D;

 

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.