Implementing a LEFT join using a lambda expression in LINQ to SQL and the Entity framework

Source: Internet
Author: User

We know that lambda expressions use the Join function in LINQ to SQL and the Entity framework to implement inner joins, so how can you implement a LEFT join in a lambda expression? The trick is to add a function DefaultIfEmpty function to the join, and in fact this function seems to only translate the inner join into a left join in LINQ, such as

var New

The returned Joinresult contains db.table1s left join DB. The result of the table2s. If you want to implement right join to return the location of Db.table1s and Db.table2s, there seems to be no good way to implement full outer join in LINQ lambda expressions, if you really use full outer Join or honestly in the database write view or stored procedures ...

Implementing a LEFT join using a lambda expression in LINQ to SQL and the Entity framework

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.