NorthwindTraders icon indicating copy to clipboard operation
NorthwindTraders copied to clipboard

[Question] Where is used AutoMapper

Open danijel88 opened this issue 4 years ago • 2 comments

Dear,

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

Regards, Danijel

danijel88 avatar May 05 '20 06:05 danijel88

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

neman avatar May 05 '20 10:05 neman

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!

Urgen-Dorjee avatar Jun 17 '20 14:06 Urgen-Dorjee

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.

jasontaylordev avatar Jul 01 '23 22:07 jasontaylordev