There are many times that when developing when you need to map an object to another object. When these situations occur, AutoMapper is the answer. It can be used for a one-to-one mapping out-of-the-box or you can easily customize the mappings to meet your needs. This also helps with only having one place to make changes when objects change or grow and more mappings are needed.
This allows just having one place to translate the objects instead of possibly many places scattered throughout the code. There will only be one place that needs to be updated when or if the objects get updated in the future. AutoMapper can also be used to combine fields such as First and Last names from one object into a Full name field in the mapped object.
In this blog, I talk about how to get started with AutoMapper for one-to-one, dynamic mapping. I’ll show an example of using AutoMapper with a basic mapping and to create a custom mapping….