I'm using Automapper in Asp.net mvc application.
I have a question regard to the usage of automapper
from lots of sample code, I saw people use mapper Mapper.Map<Target>(source)
directly in action, I'm not sure if this is good prctice, in my point of view, I would like to wrap the Mapper
code in the proxy object instead of let it talk with controller
directly
public BankflowData CreateBankflowAdjustments(BankflowData addedBankFlow)
{
var bankflow = Mapper.Map<Bankflow>(addedBankFlow);
var newBankflow = Underlying.CreateBankFlowAdjustments(bankflow);
return Mapper.Map<BankflowData>(newBankflow);
}
in this example, controller know nothing about Class Bankflow
, all it know is the dto BankflowData
.
I would like to know if this is a good practice for an application using AutoMapper?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…