Chapter 11. Mapping with AutoMapper
This chapter covers
In the previous chapter, we discussed model binders and value providers—framework components we leverage to shape input. Now we’ll focus on shaping our output, the view models that drive our views. You saw in chapter 5 how a view model shaped to the screen enables clean, maintainable markup. A logical business object should reflect the business problem, and so on. The trouble is getting all these pieces—each one fit for its purpose—talking to each other, translating.
In the companion website to his book Patterns of Enterprise Application Architecture, Martin Fowler describes a base pattern called Mapper. He says, “Sometimes you need to set up communications between two subsystems that still need to stay ignorant of each other. This may be because you can’t modify them or you can but don’t want to create dependencies between the two.” We’ll use the Mapper pattern to help our pieces talk to each other. For more information about the Mapper pattern, visit http://martinfowler.com/eaaCatalog/mapper.html.