1
I have two classes with a relation of many to many, all the mapping is already ready, the insertion is working, but when I try to do the Automapper it enters an infinite loop.
Workflow:
public class Workflow : Elemento
{
public IList<EventoWorkflow> EventosWorkflow;
}
Eventoworkflow:
public class EventoWorkflow : Evento
{
public IList<Workflow> Workflows;
}
I tried several things I found on the internet to try to make it work but none of them worked, the last attempt I made was like this:
Workflow -> Workflowdto
Mapper.CreateMap<Workflow, WorkflowDTO>()
.ForMember(x => x.EventosWorkflow, m => m.MapFrom(w => w.EventosWorkflow.Select(y => y.ActualObject).ToList()));
Eventoworkflow -> Eventoworkflowdto
Mapper.CreateMap<EventoWorkflow, EventoWorkflowDTO>()
.ConstructUsing(x => new EventoWorkflowDTO(x.CodigoEvento, AutoMapper.Mapper.Map<IList<Workflow>, List<WorkflowDTO>>(x.Workflows)));
But still he keeps making the mistake:
An unhandled Exception of type 'System.Stackoverflowexception'
Does anyone know how I can solve this problem?
Post also your DTO classes, please.
– Thiago Lunardi