Dear folks,
Is it possible to OrderByDescending a child collection property in a projection with ProjectTo
EF Core 3 seems to accomplish when i project on hand like q=>new { collection.Select(... OrderByDescending) however I wish not to project by hand. Wish to use a single ProjectTo
Appreciate any help or path
Thanks
You need to write the OrderBy in your map configuration. If you need help on how to do that, try SO.
Dear @lbargaoanu .
Appreciate your help.
Ive read about this possibility on docs. However i was hoping to have another way.
I take the opportunity to ask regarding a feature, as Iam essencially using ProjectTo() with my Dtos. And they all are mapped through Attributes (really enjoy that feature). So i was wondering have such feature to create this mapping configuration just in use or ProjectTo
Would be something like
query.Skip().Take()
.ProjectTo
.FromMember(....)// as in docs for supperseed expression rules like my needs of order by
.ToList()
Would you accept such ideia of improvement?
( that would help on keep things better placed , other than have map configs in a separeted file. I saw a PR with somethiing with ctors, couldnt understand if is it something lile this)
It doesn't seem general enough. I don't think we would accept a PR with such a feature. You could try to configure the order per call by passing parameters and using them in your mapping.
Another option is to try to apply the order in your source query, before the projection.
The order works for first level properties, but not for child collections as initial question, without mapping configuration apart.
What do you mean by passing parameters? Couldn鈥檛 figure out
http://docs.automapper.org/en/latest/Queryable-Extensions.html#parameterization
I think this is better suited for StackOverflow.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.