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

Model-level query sortings #9493

Closed
MarcoLoetscher opened this issue Aug 20, 2017 · 3 comments
Closed

Model-level query sortings #9493

MarcoLoetscher opened this issue Aug 20, 2017 · 3 comments

Comments

@MarcoLoetscher
Copy link

It would be very handy if sortings could be defined model-based.

Fluent API:
modelBuilder.Entity<Post>().HasQuerySortOrderAsc(p => p.Title);
modelBuilder.Entity<Post>().HasQuerySortOrderAsc(p => p.Title).HasQuerySortOrderDesc(p => p.Content);

Data Annotations:
[QuerySortOrderAsc] public string Title { get; set; }
or
[QuerySortOrderAsc(1)] public string Title { get; set; }
[QuerySortOrderDesc(2)] public string Content { get; set; }

Using:
var posts = context.Posts.Where(p => p.Title.StartsWith("a").ToList(); //Without the OrderBy method, "model-level query sorting" should be used
or
var blogs = context.Blogs.Include(blog => blog.Posts).ToList(); //"model-level query sorting" should be used
or
context.Entry(blog).Collection(b => b.Posts).Load(); //"model-level query sorting" should be used

Thanks Marco

@ajcvickers
Copy link
Contributor

Note for triage: I was not able to find this on the backlog, so putting it there.

@ajcvickers ajcvickers added this to the Backlog milestone Aug 25, 2017
@ajcvickers ajcvickers self-assigned this Aug 25, 2017
@smitpatel
Copy link
Contributor

duplicate of #7450 ?

@ajcvickers
Copy link
Contributor

Nice find, @smitpatel. You cal it sorting I call it ordering, let's call the whole thing off. ;-)

@ajcvickers ajcvickers removed this from the Backlog milestone Aug 25, 2017
@ajcvickers ajcvickers removed their assignment Aug 25, 2017
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants