I have two source object:
public class Book
{
public int Id {get;set;}
public IList<Unity> Unities {get;set;}
}
public class Unity
{
public int Id {get;set;}
public string Title {get;set;}
}
and three destination object:
public class DtoBook
{
public int Id {get;set;}
public DtoOrganization Organization {get;set;}
}
public class DtoOrganization
{
public int Id {get;set;}
public IList<DtoUnity> Unities {get;set;}
}
public class DtoUnity
{
public int Id {get;set;}
public string Title {get;set;}
}
I'd like to map the two source objects Book and Unity to the three dto objects but doesn't exist an Organization source object. How can I do it with Automapper?
Thanks!!!
Post my actual code Automapper code:
public static void Configure()
{
Mapper.Reset();
Mapper.CreateMap<Unity, Model.Organization>();
Mapper.CreateMap<Book, Model.Manifest>()
.ForMember(x => x.Version, y => y.UseValue("1.1"));
Mapper.AssertConfigurationIsValid();
}
public static Model.Manifest Map(Book book)
{
Configure();
Model.Manifest dtoManifest = Mapper.Map<Book, Model.Manifest>(book);
return dtoManifest;
}