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
Reacted by Arthur Vickers, Nicholas P Nelson, Adam Bezverkov, Patrick Westerhoff, Rasmus Melchior Jacobsen, Nick Muller, Lars Hanisch, Saurabh Pati, Alexei Daiter, Benedikt Radtke and 32 more
Has there been any progress with this? Ordering navigation properties still does not translate into the expected ordering in EFC5.0.5
varform=_db.Forms.Include(x =>x.Sections).ThenInclude(x =>x.Rows.OrderBy(y =>y.Order))//Nope!.ThenInclude(x =>x.Fields.OrderBy(y =>y.Order))//Nope here too!.ThenInclude(x =>x.FieldType).AsSplitQuery().SingleOrDefaultAsync(x =>x.Id==formId)
If there is no intention of ever fixing this, it might be best to show a warning when an attempt to order a navigation property is made to avoid confusion.
Reacted by Heriberto Lugo, Andele Swierstra, Jun Meng Tan and Kamol
I believe a variant of this problem is that if the included entities are of the same type (i.e. in the same table) as the primary entities. If the OrderBy specified in the include is inconsistent with the OrderBy of the primary selection, then evidently the OrderBy of the include is ignored.
This makes it more challenging to load a tree structure from a table and have the tree nodes sorted one way in the main selection (say, by name) while having the included children sorted a different way (say, by child relative position).
This is also something that should be used for any collections mapped to JSON columns.
By having a reasonable guarantee that the order is preserved we can issue partial updates that don't affect other items in the collections.
We need to modify how the collections are populated by the change tracker, so that even if some of the items were already tracked we apply the order coming from the query results.
I don't understand how the proposed feature would work. If you add a new LineItem without having loaded any Orders or LineItems, what value would it use for OrderIndex?
Activity
ajcvickers commentedon Jul 5, 2017
See also #2919
divega commentedon Jul 5, 2017
This in fact part of #2919, but I like the level of detail here.
Bitz commentedon May 19, 2021
Has there been any progress with this? Ordering navigation properties still does not translate into the expected ordering in EFC5.0.5
If there is no intention of ever fixing this, it might be best to show a warning when an attempt to order a navigation property is made to avoid confusion.
BrettGoreham commentedon Oct 25, 2021
+1 for this issue. double order bys doing nothing is very annoying especially for more complex objects
Bitz commentedon Oct 25, 2021
Hey,
I believe this will be fixed in 6.0r5
Please see #24706
Thanks
AndriySvyryd commentedon Oct 20, 2022
Related: #15585
sjb-sjb commentedon Dec 30, 2023
I believe a variant of this problem is that if the included entities are of the same type (i.e. in the same table) as the primary entities. If the OrderBy specified in the include is inconsistent with the OrderBy of the primary selection, then evidently the OrderBy of the include is ignored.
This makes it more challenging to load a tree structure from a table and have the tree nodes sorted one way in the main selection (say, by name) while having the included children sorted a different way (say, by child relative position).
AndriySvyryd commentedon Feb 15, 2024
This is also something that should be used for any collections mapped to JSON columns.
By having a reasonable guarantee that the order is preserved we can issue partial updates that don't affect other items in the collections.
We need to modify how the collections are populated by the change tracker, so that even if some of the items were already tracked we apply the order coming from the query results.
stevendarby commentedon Feb 15, 2024
I don't understand how the proposed feature would work. If you add a new LineItem without having loaded any Orders or LineItems, what value would it use for OrderIndex?
AndriySvyryd commentedon Feb 15, 2024
@stevendarby We would probably restrict this to owned collections, so there has to be always a containing Order whenever a LineItem is added.