LINQ - Join

 

LINQ Join

Sometimes you need to combine values from two data sequences that don’t have a direct relationship connecting them, using LINQ; this is where the join clause comes to the rescue. To be able to connect the two sources it has to be possible to compare equality on a shared value in both sources. For example, a video store clerk wants to match his list of arrived films with a list if film studio that has released films. A join clause could connect these two lists on the film studio id.

When a join clause compares the equality of a single property or a property of an object in the two sources it uses the special equals keyword. All joins made with the join keyword in LINQ are equijoins, which means that equality is used for comparison of the values.

LINQ joins are optimized for equijoins, but you can perform non-equijoins by using multiple from clauses and use a where clause to apply the predicate expression. The predicate expression could call the Contains method on the...

Continue Reading...
Close

50% Complete

Two Step

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.