Automapper is a library which can be downloaded through Nuget package manager, it is used to map the properties of two different classes, for example consider a scenario where you want to the data flow from reponse model to a model which needs to be serialized, then you need automapper to get involved to solve the complexityit can be done like this CreateMap(ResponseModel, Model) .ForMember(dest => dest.modelProperrty1, opt => opt.MapFrom(src.responseProperty1));like wise you can do it any number of properties. Well, that was a basic automapping , you dig deeper for complex scenarios as well
auto mapper help you to copy data from one object type to another object type. here two class person and employeepublic class Person { public string FirstName{get;set;} public string LastName{get;set;} } public class Employee { public string FirstName{get;set;} public string LastName{get;set;} public string Salary{get;set;} } now we want to transfer data from person object to employee object. auto mapper sit it between the source and destination object like bridge, and map the property data of both object.
AutoMapper is an object-object mapper which allows you to solve issues with mapping the same properties from one object of one type to another object of another type. For example, mapping a heavy entity Customer object to the CustomerDTO could be done with AutoMapper automatically.
Auto mapper is a simple reusable component which helps you to copy data from object type to other. creation and mapping: Mapper.CreateMap(); var itemModel = Mapper.Map(model);Refer: https://github.com/AutoMapper/AutoMapper/wiki/Getting-started
Auto+Mapper =AutoMapper is technique which map one object to another object. But for that we have to mapping by yourself first and from next time it will taken care Automatically. It is not about only MVC5 but for any pattern or anywhere where ever you require. good example is ETL. But as per your request in MVC5 Model is a place where you can communicate from outer world as DAL , WCF etc. So let see you car getting X data from DAL layer into model and now you are sending it controller or different layer with some business logic. Y.Name =X.FirstName+ X.LastName Y.Age= Current Date - x.DOB Something like this. On that case just we have to map your object one time and from next time it will taken care by your system .
What does Automapper do? It saves you time mapping properties with same names and types, by doing that automatically for you. You just have to tell the library which class can me mapped to another and etc. Check more detailed explanation here: https://asptemplatestack.com/Blog/PostName/asp-net-automapper-extended-use
AutoMapper is an open source library provided in GitHub.As per the AutoMapper CodePlex webpage: "AutoMapper is an object-object mapper. Object-object mapping works by transforming an input object of one type into an output object of a different type. What makes AutoMapper interesting is that it provides some interesting conventions to take the dirty work out of figuring out how to map type A to type B. As long as type B follows AutoMapper's established conventions, almost zero configuration is needed to map two types." Therefore, it provides the solution for our mapping issue.refer this link : https://www.codeproject.com/Articles/639618/CRUD-Opearations-using-AutoMapper-in-an-MVC-Applic
When we code for a realistic actual environment, we encounter many challenges to refractor our code for a better understanding and to easily identify the bugs. We mainly focus on reusability and try to move as much code as possible to a common method so that development time and maintenance costs are reduced.In this article, I will try to cover a new concept in MVC: AutoMapper. AutoMapper is used to reduce the complexity we find when binding the model and communicating with entities.