jasontaylordev / NorthwindTraders

Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Where is used AutoMapper

danijel88 opened this issue · comments

Dear,

May I know where and how it is used AutoMapper since in Upsert and Create commands I see manually Mapping.

Regards,
Danijel

You should never do auto mapping for Insert or Update. Domain model might be protected and properly encapsulated.
Auto mapping to domain model for insert makes it bad domain model and everything is exposed and you end up having anemic model instead of properly encapsulated domain model.

On the other side, auto mapping while getting data is ok and you can see the example here https://github.com/jasontaylordev/NorthwindTraders/blob/master/Src/Application/Employees/Queries/GetEmployeesList/GetEmployeesListQuery.cs

AutoMapper works fine on flat model mapping, however, with this implementation, it has issue mapping through a constructor. When I tried to map <"Source, all the fields are initialized through the constructor (private setter), Destination">. When I run the project it is looking for a parameterless constructor and hence all the fields are null/empty. I don't know how you can make this with constructor initialization. Thanks!

Thank you for your interest in this project. This repository has been archived and is no longer actively maintained or supported. We appreciate your understanding. Feel free to explore the codebase and adapt it to your own needs if it serves as a useful reference. If you have any further questions or concerns, please refer to the README for more information.