DEV Community

Discussion on: Clean code architecture and CQRS pattern based web api using .NetCore

Collapse
 
silentrobi profile image
Mohammad Abu Musa RABIUL • Edited

The reason is that your entity might have more parameters and your client doesnt need all those parameters. So, you create a DTO of what parameters your client want. For an example, client wants only name and age of an user. However, your entity has more information than that like telno, address, designation etc. Therefore, in order to provide what client wants, you create your custom DTO that contains only name and user property.

Collapse
 
1304654 profile image
1304654

I understand. But in the case of return the same properties. It should be better return the entity instead of "duplicate " the object contract? Thank for the response.

Thread Thread
 
silentrobi profile image
Mohammad Abu Musa RABIUL

You can do that if you need to return exact entity.