I have need to map PriorityId -> TcTaskPriorityId
Mapper.Configuration.RecognizePrefixes("TcTask");
Mapper.CreateMap<Task, TpTasksEntity>();
Task t = new Task{PriorityId = 1};
var te = Mapper.Map<Task, TpTasksEntity>(t);
It just does not work.
The RecognizePrefixes works for source object prefixes, i.e.:
Mapper.Configuration.RecognizePrefixes("TcTask");
Mapper.CreateMap<Task, TpTasksEntity>();
Task t = new Task { TcTaskPriorityId = 1 };
var te = Mapper.Map<Task, TpTasksEntity>(t);
For your scenario you could write a custom naming convention:
Mapper.Configuration.SourceMemberNameTransformer = s => "TcTask" + s;
Mapper.CreateMap<Task, TpTasksEntity>();
Task t = new Task { PriorityId = 1 };
var te = Mapper.Map<Task, TpTasksEntity>(t);
Use RecognizeDestinationPrefixes method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With