I have an EF EF generated Person class that has several properties. I also have a Jobs class with several properties. A person is associated with several tasks, and therefore, Jobs is a collection property of a person.
I created a view model as such:
public class PersonViewModel
{
public Person Person{ get; set; }
public List<Job> Jobs{ get; set; }
}
From my point of view, I am sending an instance of PersonViewModel. I would like to use AutoMapper to map this view model to an instance of Person with a task collection property populated with a list from the view model.
Can this be done? So far I have tried:
Mapper.CreateMap<PersonViewModel, Person>();
no luck ...
EDIT:
OK, this really works. I found that I have a problem elsewhere ...
My Person one-many PersonType... PersonType Person, auto mapper ... ... PersonTypeID . , , . ...
2:
, Person PersonTypeID ( PersonType)... Person as PersonType...
, , , , PersonTypeID Person ...
automapper, , PersonType nav Person ... AutoMapper.AutoMapperMappingException
Destination property: PersonType
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.