简体   繁体   中英

Order of AfterMap in Automapper

Is there any way to specify which AfterMap function should be executed first? For example I have this code:

 cfg.CreateMap<ClassA, ClassA_DTO>()
                 .AfterMap((source, dest) => ...
                 .AfterMap((source, dest) => ...
                 .AfterMap((source, dest) => ...


 //I need this aftermap to be executed first.
 cfg.CreateMap<ClassB, ClassB_DTO>().AfterMap((src, dest) =>
 {
     foreach (var ... in ...)
     {

     }
 });

But the problem is that ClassA contains ClassB.

No, there isn't, and I probably won't add it. It's way too confusing. I'm not sure what you're trying to do in your mapping, but this much custom configuration might be a good case of manually mapping things, which is as explicit and obvious as you can get.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM