Skip to content

Instantly share code, notes, and snippets.

@jeremybeavon
Created April 9, 2015 19:22
Show Gist options
  • Save jeremybeavon/1b7bba7d7bdc4b784005 to your computer and use it in GitHub Desktop.
Save jeremybeavon/1b7bba7d7bdc4b784005 to your computer and use it in GitHub Desktop.
LINQ Join Complex Condition
public static IEnumerable<TResult> Join<TOuter, TInner, TResult>(
this IEnumerable<TOuter> outer,
IEnumerable<TInner> inner,
Func<TOuter, TInner, bool> condition,
Func<TOuter, TInner, TResult> resultSelector)
{
return from outerItem in outer
from innerItem in inner
where condition(outerItem, innerItem)
select resultSelector(outerItem, innerItem);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment