You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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 usedor
var blogs = context.Blogs.Include(blog => blog.Posts).ToList();
//"model-level query sorting" should be usedor
context.Entry(blog).Collection(b => b.Posts).Load();
//"model-level query sorting" should be usedThanks Marco
The text was updated successfully, but these errors were encountered: