Skip to content
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

Introduce generic math LINQ operators #71901

Closed
roji opened this issue Jul 10, 2022 · 3 comments
Closed

Introduce generic math LINQ operators #71901

roji opened this issue Jul 10, 2022 · 3 comments

Comments

@roji
Copy link
Member

roji commented Jul 10, 2022

With generic math coming in C# 11, we can introduce generic versions of math LINQ operators. These would include Average, Sum, Max, Min, and would allow e.g. representing math over date/time types (e.g. TimeSpan).

Note that if we end up implementing an identity ordering operator (without a key selector), as per #14729, we may want to think about what role, if any, IComparisonOperators would play there. In theory, either IComparable or IComparisonOperators is sufficient for such an operator.

Note that this would include both enumerable and queryable versions. I specifically ran into this while considering how to represent a sum of time intervals operation for translation to SQL with EF Core. A generic Sum method would be perfect for that (TimeSpan would also to implement the appropriate interfaces as well).

/cc @tannergooding @ajcvickers

@roji roji added enhancement Product code improvement that does NOT require public API changes/additions area-System.Linq labels Jul 10, 2022
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 10, 2022
@ghost
Copy link

ghost commented Jul 10, 2022

Tagging subscribers to this area: @dotnet/area-system-linq
See info in area-owners.md if you want to be subscribed.

Issue Details

With generic math coming in C# 11, we can introduce generic versions of math LINQ operators. These would include Average, Sum, Max, Min, and would allow e.g. representing math over date/time types (e.g. TimeSpan).

Note that if we end up implementing an identity ordering operator (without a key selector), as per #14729, we may want to think about what role, if any, IComparisonOperators would play there. In theory, either IComparable or IComparisonOperators is sufficient for such an operator.

Note that this would include both enumerable and queryable versions. I specifically ran into this while considering how to represent a sum of time intervals operation for translation to SQL with EF Core. A generic Sum method would be perfect for that (TimeSpan would also to implement the appropriate interfaces as well).

Author: roji
Assignees: -
Labels:

enhancement, area-System.Linq

Milestone: -

@stephentoub
Copy link
Member

Duplicate of #64031

@stephentoub stephentoub marked this as a duplicate of #64031 Jul 10, 2022
@roji
Copy link
Member Author

roji commented Jul 10, 2022

Thanks, somehow missed this in my searches.

@roji roji closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jul 10, 2022
@roji roji added duplicate and removed enhancement Product code improvement that does NOT require public API changes/additions area-System.Linq labels Jul 10, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants