I am using Automapper in an asp.net mvc application. I have a question regarding the use of automapper
from a lot of code examples, I saw that people use the mapper Mapper.Map<Target>(source) directly in action, I'm not sure if this is a good prctice, from my point of view, I would like to wrap the Mapper code in a proxy object instead of letting him talk directly to the controller
public BankflowData CreateBankflowAdjustments(BankflowData addedBankFlow) { var bankflow = Mapper.Map<Bankflow>(addedBankFlow); var newBankflow = Underlying.CreateBankFlowAdjustments(bankflow); return Mapper.Map<BankflowData>(newBankflow); }
in this example, the controller does not know anything about the Bankflow class, all it knows is dto BankflowData .
I would like to know if this is good practice for an application using AutoMapper?
source share