Dharmik wrote:What is need of AutoMapperStartupTask.cs and MappingExtensions.cs files...???
Thank You...
Hi Dharmik,
AutoMapperStartupTask initializes a library that will automatically map one object type to another object type. For example without AutoMapper a developer would need to write code like this:
Product p = new Product();
p.Id = 1;
p.Name = "Product One";
ProductModel model = new ProductModel();
model.Id = p.Id;
model.Name = p.Name;
Instead of typing all of that code a developer can simply use AutoMapper to do the mappings.
Product p = new Product();
p.Id = 1;
p.Name = "Product One";
ProductModel model = Mapper.Map<Product,ProductModel>(p);
The extensions create a fluent interface (using extension methods) for developers to call mapping logic. Instead of the last line of code in the sample above a developer can now write:
ProductModel model = p.ToModel();
Currently these classes are used mainly in the Administration applications and they are not used in every possible situation. I hope this helps clarify what they are for.
p.s. The startup task runs when the application starts and registers all the possible mappings that can take place.