0

I'm currently defining my map like this:

CreateMap<Request, RequestDetailsDTO>()
    .ForMember(dto => dto.Approvals, conf => conf.MapFrom(x => x.ApprovalStatus.OrderBy(x => x.Position)));

but now I'm wanting to switch to using attributes on the RequestDetailsDTO instead. Is it possible to specify the ordering with an attribute, or does that require I stick with the fluent version?

For example, it would be nice to be able to do something like this:

[AutoMap(typeof(Request))]
public class RequestDetailsDTO {
    [SourceMember(nameof(ApprovalStatus), OrderBy = nameof(ApprovalStatus.Position)]
    public IEnumerable<RequestApprovalStatusDTO> Approvals { get; set; } = default!;
Gargoyle
  • 9,590
  • 16
  • 80
  • 145
  • What kind of attribute are you thinking of? Applied where? How that attribute would look like? Can you share a sample code, doesn't need to be compilable. Remember that attributes require compile time known values. – Prolog Nov 13 '20 at 18:48
  • @Prolog I updated the question with a possible example. – Gargoyle Nov 13 '20 at 18:58

0 Answers0