Last post Oct 10, 2016 02:20 AM by Cathy Zou
Sep 26, 2016 06:37 PM|sudip_inn|LINK
please help me to understand left outer join or right outer join query compose in EF and LINQ. which indicate the query is left outer join or right outer join ?
help me to understand this. thanks
Sep 27, 2016 02:26 AM|Cathy Zou|LINK
An Outer Join (also known as a Left Join or Right Join) is a one-to-many join, where each record in one set of data can be matched up with multiple records in another set of data, based on common fields. In a SQL SELECT statement, the second set of data is
specified in a LEFT JOIN or RIGHT JOIN clause, and the equalities used to join them are specified in an ON clause. In a LEFT JOIN, every record in the first (left) set of data is joined with all records in the second set of data that match it based on the
join expressions. Every record in this first set of data will appear in the result, whether or not it matches anything in the second set. This is reversed in a RIGHT JOIN, where everything in the second (right) set of data appears and is matched to everything
possible in the first set.
left outer join: A left outer join is a join in which each element of the first collection is returned, regardless of whether it has any correlated elements in the second collection. You can use LINQ to perform a left outer join by calling the DefaultIfEmpty<TSource>
method on the results of a group join.
Besides, The only difference between ordinary joins (inner joins) and left joins in LINQ is the use of “join into” and “DefaultIfEmpty()” expressions.
For more detailed information about left outer join or right outer join, you could refer to the following links:
Hope this can help you. If you have any question and confusion about the problem. Please don't hesitate to let me know.
Sep 27, 2016 08:25 AM|sudip_inn|LINK
@Cathy i asked very simple question that when some one will see a LINQ query then what special code should there which indicate the query is left join or right join.
so please post a sample left join query with linq and tell me which area indicate in code indicate the query is left join. thanks
Oct 06, 2016 09:57 AM|Cathy Zou|LINK
From official document, there three are three most common join types:
•Left outer join
In linq, right is relative to Left outer join, look at following explaination.
there are relative according two tables position.
Oct 06, 2016 12:11 PM|sudip_inn|LINK
i found no difference between your two linq query. thanks
Oct 10, 2016 02:20 AM|Cathy Zou|LINK
I did not describe clearly. My means is that there is no right outer join in linq, it is relative to Left outer join, as the above picture display, the position of two tables is different. So, if the first is a right outer join and the second will become to
be a Left outer join.