Coalesce
Coalesce copied to clipboard
[API] Remove default ordering by properties called "Name"
Situation: I have a collection of objects that I want to return from an API in a specific order. These objects have a Name
property on them. Coalesce takes over the ordering of this collection when mapping to the DTO, re-ordering them by Name
and discarding my original ordering.
This behavior is pretty unintuitive, and would likely be hard for someone who isn't extensively experienced with Coalesce to figure out why its happening. While the auto-sorting by Name
can often be useful, there is no way to suppress this behavior other than placing ordering attributes on another property, which I can't do in the situation described - there are no properties on the data that I'm ordering by - I simply want to maintain the original order of the items as they were placed in the collection.
On the flip side, if someone DOES want to order by Name
, its very easy to add this behavior manually.
The default ordering fallback to primary key is also worth considering for removal, but only when mapping child collections - the default ordering by primary key of the root data being returned from the /list
endpoint should remain.
@GrantErickson - thoughts?
Seems reasonable. Was the original ordering behavior there to make select lists automatically ordered?
Another option would be to have slightly different default ordering behavior for top-level list results from a /list
endpoint vs the ordering of child collections in the DTO mapping. Keep /list
endpoints having the default ordering of their root data fall back to Name
/primary key, but don't use the Name
fallback default for child collections.
I do believe that is the intention by the default ordering by Name
, yes.
The key here is to keep the admin pages sorted in a good default way.
Doing nothing here for 3.0 because we haven't ran into this problem in a while. When someone runs into it again, we can re-evaluate and see if we can come up with a solution that makes sense. I don't know that removing the default ordering is the right solution here - I think the solution lies closer to a way that you could suppress the default ordering.