Skip to content

Instantly share code, notes, and snippets.

@randomcodenz
Created July 16, 2012 05:03
Show Gist options
  • Save randomcodenz/3120697 to your computer and use it in GitHub Desktop.
Save randomcodenz/3120697 to your computer and use it in GitHub Desktop.
Outer join extension
public static class OuterJoinExtensions
{
public static IEnumerable<TResult> LeftOuterJoin( this IEnumerable<TLeft> left, IEnumerable<TRight> right, Func<TLeft, TLefTKey> leftKey, Func<TRight,TRightKey> rightKey, Func<TLeft,TRight,TResult> resultSelector )
{
return left.GroupJoin( right, leftKey, rightKey, (key,matches) => { Key = key, Matches = matches })
.SelectMany( x => x.Matches.DefaultIfEmpty(), resultSelector);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment