[API Proposal]: linq "from" clause without "on" #7585
Unanswered
vmikhailov
asked this question in
Language Ideas
Replies: 2 comments 6 replies
-
How does a different syntax address any of the other concerns? The behavior of the |
Beta Was this translation helpful? Give feedback.
3 replies
-
Not sure why do you think it does not solve the performance issue. The proposal describes syntax improvements for the join which solves the issues by itself |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background and motivation
The idea behind the new API is to improve readability and performance. Currently, the intuitive and compact way to write cross joins for multiple collections is to use multiple "from" clauses. The drawback of the existing approach is multiple enumerations of each nested "from" source.
As far as the code above translates into nested SelectMany the GetData2 and GetData3 methods will be executed multiple times. GetData2() will be executed GetData1().Count times, while GetData3() will be executed GetData1().Count * GetData2().Count. The behaviour is not obvious and could cause unexpected performance drop.
Alternative option is to use join
In this case all the GetData* methods will be executed just once which is way more effective
API Proposal
One possible solution would be to make the "on " clause optional.
also corresponding CrossJoin/Join chain methods will be needed.
API Usage
see the API proposal
Alternative Designs
Alternatively one more keyword "cross" could be added.
Risks
No response
Beta Was this translation helpful? Give feedback.
All reactions