score:3

Accepted answer

It would be something like this:

Dim JoinedResult = From t1 In Table1 
    Group Join t2 In Table2 
       On t1.key Equals t2.key 
       Into RightTableResults = Group 
    From t2 In RightTableResults.DefaultIfEmpty 
    Select t1.Prop1, 
       t2.Prop2        

I'm not a VB guy (anymore), but I think this would work.

score:0

You can simply use the existing Join method

public static IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(
    this IEnumerable<TOuter> outer,
    IEnumerable<TInner> inner,
    Func<TOuter, TKey> outerKeySelector,
    Func<TInner, TKey> innerKeySelector,
    Func<TOuter, TInner, TResult> resultSelector
)

eg:

table1.Join(table2, t1 => t1.Key, t2 => t2.Key, (t1, t2) => new { Table1 = t1, Table2 = t2 });

can find more overloads and examples http://msdn.microsoft.com/en-us/library/system.linq.enumerable.join.aspx

Pardon me for c# examples


Related Articles