The difference between a LINQ to entity left join right connection and an inner join notation

Source: Internet
Author: User

What's the difference between a LINQ to entity left-connected right connection and an inner join notation, and how to write with a lambda expression, which is more efficient?

[Workaround]
Left join right or connected this actually you don't need to care. Just write the query based on the mapping of the entity, and the framework will automatically help you build it.
As for the efficiency of LINQ query syntax and extension methods, it should be the same, for example:

C # code
var users= (from U in db. Users where u.userroleid==1 select u). ToList (); var users2=db. Users.where (u=>u.userroleid==1). ToList ();
[Workaround]
INNER JOIN:
var =from x in db. T1
Join Y in db. T2
On X.yid equals y.id
Select X;

Left JOIN:

var =from x in db. T1
Join Y in db. T2
On X.yid equals y.id into Temp
From Y in temp. Defalutifempty ()
Select New{x.id,name=y==null? ": Y.name};

Right join principle with LEFT Join

As for efficiency, LAMDA expressions are the same as standard expressions
[Workaround]
A LINQ expression is a lambda expression that, for a database, translates to SQL running on the database side, so it's as efficient.
[Workaround]
Take a look at the sixth article.

And a friend upstairs, LINQ to EF, with from- x in temp. Defalutifempty () is not a hundred percent execution left connected

LINQ to entity left join right joins and differences in inner joins (go)

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.