Tengo la siguiente estructura de Request y Response:
public class Action
{
public class Create
{
public class Request
{
public string operationdate { get; set; }
public string action { get; set; }
public string identificationaccount { get; set; }
public string observation { get; set; }
private ErrorModel.Error errorrow = new ErrorModel.Error();
public ErrorModel.Error ErrorRow { get { return errorrow; } set { errorrow = value; } }
}
public class Response : Request
{
public Int32 version { get; set; }
public string groupcode { get; set; }
public bool active { get; set; }
}
}
}
y quiero mapear a la siguiente estructura de DTO:
public class GroupDTO
{
public Int64 idGroup { get; set; }
public string GroupCode { get; set; }
public string GroupDate { get; set; }
public string Obs01 { get; set; }
public string Obs02 { get; set; }
public string Obs03 { get; set; }
public string Obs04 { get; set; }
public bool Active { get; set; }
private List<ActionModelDTO> _Actions = new List<ActionModelDTO>();
public List<ActionModelDTO> Actions { get { return _Actions; } set { _Actions = value; } }
}
public class ActionModelDTO
{
public Int64 idAction { get; set; }
public string ActionDate { get; set; }
public Int32 Version { get; set; }
public Int32 idGroup { get; set; }
public bool Active { get; set; }
private ActionDetailModelDTO _ActionDetailModel = new ActionDetailModelDTO();
public ActionDetailModelDTO ActionDetailModel { get { return _ActionDetailModel; } set { _ActionDetailModel = value; } }
private ActionUserDetailModelDTO _ActionUserDetailModel = new ActionUserDetailModelDTO();
public ActionUserDetailModelDTO ActionUserDetailModel { get { return _ActionUserDetailModel; } set { _ActionUserDetailModel = value; } }
}
public class ActionDetailModelDTO
{
public Int64 idActionDetailModel { get; set; }
public Int32 idActionType { get; set; }
public string ActionType { get; set; }
}
public class ActionUserDetailModelDTO
{
public Int64 idActionUserDetailModel { get; set; }
public string UserAccount { get; set; }
public string UserObservation { get; set; }
public string IdentificationNumber { get; set; }
}
El mapeo sería el siguiente:
- Action.Create.Request.operationdate => ActionModelDTO.ActionDate
- Action.Create.Request.action => ActionDetailModelDTO.ActionType
- Action.Create.Request.identificationaccount => ActionUserDetailModelDTO.UserAccount
- Action.Create.Request.observation => ActionUserDetailModelDTO.UserObservation
El objeto al que se tendría que mapear es GroupDTO... es la primera vez que uso Automapper, y me devuelve el siguiente error:
Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters
Los campos que no figuran en el mapeo que especifiqué se completan luego que el objeto se persista en DB.