I have a problem with my AutoMapper configuration, I can map for one level but I don't know if there exists a way to map for two levels
I have:
Class A
{
public int id {get; set;}
public string nom {get; set;}
public B Bprop {get; set;}
}
Class B
{
public int id {get; set;}
public string nom {get; set;}
public C Cprop {get; set;}
}
Class C
{
public int id {get; set;}
public string nom {get; set;}
}
My code for configuration is below, and it works if I delete Cprop
from class B
:
MapperTools<DatabaseA, A> mapperToolsService =
new MapperTools<DatabaseA, A>(MappingHelper);
mapperToolsService.MappingConfig.Configuration.CreateMap<DatabaseA, A>()
.ForMember(dest => dest.Bprop , opt => opt.MapFrom(src => src.DatabaseB));
mapperToolsService.MappingConfig.Configuration.CreateMap<DatabaseB,B>();
Please, what is wrong with my code?