-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add Join/LeftJoin/RightJoin tuple overloads to LINQ APIs #121998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… AsyncEnumerable Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
| public static System.Collections.Generic.IEnumerable<TSource> Intersect<TSource>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TSource> second, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; } | ||
| public static System.Collections.Generic.IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this System.Collections.Generic.IEnumerable<TOuter> outer, System.Collections.Generic.IEnumerable<TInner> inner, System.Func<TOuter, TKey> outerKeySelector, System.Func<TInner, TKey> innerKeySelector, System.Func<TOuter, TInner, TResult> resultSelector) { throw null; } | ||
| public static System.Collections.Generic.IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this System.Collections.Generic.IEnumerable<TOuter> outer, System.Collections.Generic.IEnumerable<TInner> inner, System.Func<TOuter, TKey> outerKeySelector, System.Func<TInner, TKey> innerKeySelector, System.Func<TOuter, TInner, TResult> resultSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer) { throw null; } | ||
| public static System.Collections.Generic.IEnumerable<(TOuter Outer, TInner Inner)> Join<TOuter, TInner, TKey>(this System.Collections.Generic.IEnumerable<TOuter> outer, System.Collections.Generic.IEnumerable<TInner> inner, System.Func<TOuter, TKey> outerKeySelector, System.Func<TInner, TKey> innerKeySelector) { throw null; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Please remove this overload, replacing it with a single overload that has an optional IEqualitComparer parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot check that this is the case with all overloads across projects as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7f53b70. Consolidated the two overloads into a single overload with IEqualityComparer<TKey>? comparer = null for all Join, LeftJoin, and RightJoin tuple-returning methods in Enumerable and Queryable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified - all tuple-returning overloads across all three projects use the single overload with optional IEqualityComparer<TKey>? comparer = null pattern:
- System.Linq: Join, LeftJoin, RightJoin (1 overload each)
- System.Linq.Queryable: Join, LeftJoin, RightJoin (1 overload each)
- System.Linq.AsyncEnumerable: Join, LeftJoin, RightJoin (2 overloads each - one for sync key selectors, one for async key selectors, both with
comparer = null)
…omparer parameter Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Implements tuple-returning overloads for
Join,LeftJoin, andRightJointhat eliminate the need for aresultSelectorlambda when you just want the joined elements as a tuple.Changes
Join<TOuter, TInner, TKey>,LeftJoin<TOuter, TInner, TKey>,RightJoin<TOuter, TInner, TKey>returning(TOuter Outer, TInner Inner)tuples (with nullable element for outer joins)Expression<Func<>>key selectorsIEqualityComparer<TKey>? comparer = nullparameterExample
Before:
After:
Fixes #108799
Original prompt
This section details on the original issue you should resolve
<issue_title>[API Proposal]: Linq Join return tuple similar to Zip</issue_title>
<issue_description>### Background and motivation
For simplicity of
Joinit should just return(TOuter,TInner)instead of the need forresultSelectorAPI Proposal
API Usage
Alternative Designs
Without this it need to make another lambda just for return tuple