I have about this code:

CreateMap<Entity, EntityResponse>(); // #1 CreateMap<Source<Entity>, Dest<EntityResponse>>() .ConvertUsing(source => { // здесь мне нужно вызвать маппинг описанный в строке 1# EntityResponse resp = <mapping>; int someInt = source.SomeInt; string someStr = source.SomeString; return new Dest(resp, someInt, someString); }); 

The class Dest has such a constructor:

 Dest(EntityResponse item, int someInt, string someStr) 

How do I call the mapping from Entity to EntityResponse ? Thank you in advance

  • why do you in CreateMap <Source <Entity>, Dest <EntityResponse >> () specify Source <> and Dest <> what it will be - Yaroslav
  • look here: stackoverflow.com/q/832091/261244 - Yaroslav

1 answer 1

On the go, you can

 cfg.CreateMap<Source<Entity>, Dest<EntityResponse>>(). ConstructUsing((source,context) => { EntityResponse resp = context.Mapper.Map<EntityResponse>(source.Entity); int someInt = source.SomeInt; string someStr = source.SomeString; return new Dest(resp, someInt, someString); }).ForAllMembers(s => s.Ignore());