Linq left join, inner join, crossjoin, linqcrossjoin

Source: Internet
Author: User

Linq left join, inner join, crossjoin, linqcrossjoin
Inner join:

 

By default, the Join method of Inner Join is used in linq. the following expressions are the same:

 

Left Join:

The left link returns all the data in the left table, and the data that meets the link conditions and does not meet the link conditions in the right table. The field values are not met,

In case of one to multiple tables, the data in the primary table is duplicated,

 

 

 

The implementation method of the left outer link is as follows. Note that the difference between this method and the above method is that an Into n is created after the link, and n is a list of SalesOrderDetails at this time,

If you want to return SalesOrderDetails data, you need to add another step from b2 in n. DefaultIfEmpty () and then access the data column of SalesOrderDetails through b2,

If you want to implement the right link, you only need to change the location of the corresponding table,

To translate orderitemid = b2.Id into SQL, an alias is obtained for b2.Id,

 

Note: If a sentence d = b2 is added, the generated SQL statement will generate a very complex SQL statement as follows,

Cross Join Cartesian Product

 

 

 

 

Cross

Related Article

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.