Open
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-linq |
Author
|
@dotnet-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive usage examples for the new .NET 9 Enumerable.AggregateBy method. These examples are designed to help developers understand the difference between using a constant seed and a seed selector for stateful aggregations.
Examples Added:
Multi-value Aggregation (seedSelector): Demonstrates using a tuple (Total, Count) to compute both the sum and the frequency of elements per group in a single pass.
Simple Summation (seed): Illustrates the use of a constant decimal seed to calculate total values (salaries) grouped by a key (department).
Technical Highlights:
Efficiency: The examples emphasize the benefit of AggregateBy over GroupBy by avoiding the allocation of intermediate grouping collections.
Real-world Context: Uses an Employee class scenario to make the utility of the API immediately clear to developers.
Each example includes input data, the LINQ implementation, and the expected console output.