-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[API Implementation]: Add Order
and OrderDescending
to Enumerable
and Queryable
#70525
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/area-system-linq Issue DetailsProposal implementation of #67194 closes #67194) Proposalnamespace System.Linq
{
public partial class Enumerable
{
public static IOrderedEnumerable<T> Order<T>(this IEnumerable<T> source);
public static IOrderedEnumerable<T> Order<T>(this IEnumerable<T> source, IComparer<T> comparer);
public static IOrderedEnumerable<T> OrderDescending<T>(this IEnumerable<T> source);
public static IOrderedEnumerable<T> OrderDescending<T>(this IEnumerable<T> source, IComparer<T> comparer);
}
public partial class Queryable
{
// Or whatever's correct.
[DynamicDependency("Order`1", typeof(Enumerable))]
public static IOrderedQueryable<T> Order<T>(this IQueryable<T> source);
[DynamicDependency("Order`1", typeof(Enumerable))]
public static IOrderedQueryable<T> Order<T>(this IQueryable<T> source, IComparer<T> comparer);
[DynamicDependency("OrderDescending`1", typeof(Enumerable))]
public static IOrderedQueryable<T> OrderDescending<T>(this IQueryable<T> source);
[DynamicDependency("OrderDescending`1", typeof(Enumerable))]
public static IOrderedQueryable<T> OrderDescending<T>(this IQueryable<T> source, IComparer<T> comparer);
}
} Current state of implementation
Footnotes
|
I don't think there is no way queryable can implement this new API in a more performant way than enumerable now does, as there is no documented way to introspect the comparer and somehow handle that on a repository layer. In that case: is it useful to add the helper on |
|
Ugh. I copied and pasted the code from main but it looks like fat arrow formatting was different. Should be fixed now. |
@eiriktsarpalis Thank you. I think this is ready-to-merge. Or do you have concerns (then we could ask a 2nd reviewer)? |
I think this API might not be bad for the announcements in the next preview version. Many people work with LINQ so this is probably a relatively interesting API. |
@deeprobin Would you like to add a short announcement in the Preview 7 issue? |
@eiriktsarpalis dotnet/core#7455 (comment) suggestions? |
Looks good overall, I would skip the API shape and just focus on the final code sample. It should be enough to communicate the background and motivation. |
I removed the api shape 👍🏼 |
Thanks @deeprobin ! |
Proposal implementation of #67194 (closes #67194)
Proposal
Current state of implementation
/cc @terrajobst
Footnotes
I have implemented only the most important test cases, as I would imagine that the complex cases are flaky.
If desired, I can also implement more test cases. ↩
Copied from the Microsoft Docs from the OrderBy overloads and adjusted accordingly. ↩