How to implement your mapping of objects in ASP NET MVC CORE?

This question
I was told that Automapper it is better not to use
How then to be with my implementation of the mapper without displaying c#
Toist I need for each DTOшки for each VIewModel to use and create your own mapper class?
For example there
public class RoleMapperUpdateModel : IMapper<RoleDTO, UpdateRoleViewModel>
 public UpdateRoleViewModel Map(RoleDTO source)
 return new UpdateRoleViewModel()
 Id = source.Id
 Name = source.Name
 Users = source.Users

 public RoleDTO MapBack(UpdateRoleViewModel destination)
 return new RoleDTO()
 Id = destination.Id
 Name = destination.Name
 Users = destination.Users

and so for all
If Yes how then to be?
To make better mapper in a separate project and use it in the logic layer and the view layer
Or better still on different layers to create just the daddy with all classes of the mapper?
Thanks in advance?
April 19th 20 at 12:20
1 answer
April 19th 20 at 12:22
You may want to ask
I was told that Automapper it is better not to use

And remind him about the principle not to invent another Bicycle?
But he insists that when using the mapper errors out in runtime - Carson commented on April 19th 20 at 12:25
@Carson, an Example of the error and why it will not occur in your approach?
Mapper does exactly what he is told. In simple cases, it procedue all the fields on other fields.
In complicated cases the calculations go, but why to do the calculations in mapera? Maybe just an ill-conceived architecture. By the way this is all theoretical speculation. If there is code to talk to the subject. - Maritza27 commented on April 19th 20 at 12:28
@Maritza27, well firstly as I understand it, automapper working very long, and if it to prescribe pens, it works faster.
Secondly if I change the field names, it mapitse will not open the attachment for specific field names
Well, errors occur when it is not clear why a field is not to mapitse
Or when one field be a foreign key in another entity
For example I have a User Bank, he has an account Identity Asp NEt core
communication one-to-one on the field appUserFK
And mapper will be mappit id user id appUSerа
And I want mappilas id appUserа on FK
Or where in the ViewModel I don't need FK, I need to use Ignore for this field - Carson commented on April 19th 20 at 12:31
@Carson, As I understand it uses reflection. Yes, it's not fast.
But the final answer you can only give the Profiler or metrics that you will collect on the prod.
About it is unclear, to pass all the tests. That is, there was a situation. You cover the dough, and transfer it back to green status.

And Yes what you have described is not the fault of the mapper, and your error, module telepathy there. - Maritza27 commented on April 19th 20 at 12:34
@Maritza27, you know. I would have just used Automapper
But in this case, as it is better to be? To use for each proect your mappers or create a common project with all mappers? - Carson commented on April 19th 20 at 12:37
@Carson, I don't see the project. So just advise to position them in the place of use.
And do not have universal solutions, they are usually more complicated. Leave your code simple. - Maritza27 commented on April 19th 20 at 12:40
@Maritza27, thank you)
It is normal that muppet you need lots especially for the ViewModel?
Or this follows from the fact that it is not built properly the subject area? - Carson commented on April 19th 20 at 12:43
@Carson, yeah, At least. If complex data, and ViewModel grows, especially if a lot of different behaviors out there. - Maritza27 commented on April 19th 20 at 12:46

Find more questions by tags ASP.NET