Open gy-szabo opened 4 months ago
Here is a typical scenario in real life apps:
The get by id part is ok, let’s focus on the get list part.
If we see only 5 of the 25 columns of the data for each table row, why should we send more? If we send more than enough then we essentially increase the communication time between the api and client. Moreover, we might even create larger db queries, therefore making the db communication slower as well. This is a problem, but it can be solved.
This is where DTOs come in. DTOs are basically objects that in terms of data are either:
Right now we have endpoints that either require or provide the
Customer
entity objects. In order to save processing power and make the api more customisable, the api should only accept and provide DTO objects.In code this means:
CustomerDTO
and aCustomerListItemDTO
class