hello team,
For this new update of ANZ v5, I notice that the DTOs don't use attributes for auto mapping anymore.. instead, all are declared in CustomDtoMapper.
May I know the reason, and should we still continue using auto mapping via attributes or change all mapping definitions to follow your practise and declare inside CustomDtoMapper? Thank you.
4 Answer(s)
-
0
hi
the main reason is layer discrimination . When defining AutoMap as attribute, you have to use Entity in the attribute, thus you have to reference to the Coreproject. As you notice Application.Shared project doesn't get any reference from Core project. It is only referencedCore.Shared project. What's the benefit of this approach? Answer: If you think Xamarin UI as a client, it's not dependent on Application Services > Repositories. It implements the Application Service Interfaces via HTTP client.
I hope I could clearly express ;)
-
0
thank you for you reply,
I think I understand what you mean.. is it based on the I in SOLID principle??
The interface-segregation principle (ISP) states that no client should be forced to depend on methods it does not use
It was so convenient with those attributes, but thats alright.. I have another question that relates.. So for certain attributes that used to be taken from the entity, what is the best practice to do so now? For example, my MaxLength attribute on Name in the dto, I used to just call [MaxLength(MyEntity.MaxNameLength)], but now we do not reference the entity and we can't do that anymore.. Is it ok to repeat them or is there another way to do so?
Thank you.
-
0
After reading through more on the source code, I think I understand more. The sharing of Entity Code will be in Core.Shared project. Thank you.
-
0
That's it! I know obeying SOLID rules makes software more complicated. But for long term it's always good. Imagine there are no traffic lights, we'll go faster without waiting red light, but we'll run into some troubles... Happy coding ;)