Mapping Domain Model to Entity Model

Sep 12, 2012 at 5:27 PM
Edited Sep 12, 2012 at 5:30 PM

Studying this project I see that Automapper is used in the MVC Controllers to Map a ViewModel onto the DomainModel (Command). 

 

var command = Mapper.Map<CategoryFormModel, CreateOrUpdateCategoryCommand>(form);

 


Moving on to CreateOfUpdateCategoryHander.Execute() 

I see that the DomainModel is then manually mapped to the EntityModel (Category):

var category = new Category
            {
                CategoryId = command.CategoryId,
                Name = command.Name,
                Description = command.Description
            };



 I'm new to Automapper, having just been introduced to it, but why isn't it used here at well? Like such:

var category = Mapper.Map<CreateOrUpdateCategoryCommand, Category>(command);

 
Thanks for the help. This project is an amazing resource I just want to study it well.