I have my classes that looks like this :
public class Student{
public string Name { get; set; }
public string Id { get; set; }
public List<Course> Courses { get; set; }
public string Address { get; set; }
}
public class Course{
public string Id { get; set; }
public string Description { get; set; }
public Date Hour { get; set; }
}
And i want to map the Student class to the following one using AutoMapper
public class StudentModel{
public string Id { get; set; }
public StudentProperties Properties { get; set; }
}
where StudentProperties is the remaining properties of the student class
public class StudentProperties{
public string Name { get; set; }
public List<Course> Courses { get; set; }
public string Address { get; set; }
}
based on the AutoMapper documentation (https://github.com/AutoMapper/AutoMapper/wiki) we can use custom resolver to solve destination member while performing the mapping. But i don't want to add new class for the resolver.
I'm wondering if there is a simple way to perform the mapping by just doing simple configuration like this :
Mapper.Initialize(cfg =>
{
cfg.CreateMap<Student, StudentProperties>();
cfg.CreateMap<Student, StudentModel>();
});