F
F
forced2022-04-15 14:08:59
.NET
forced, 2022-04-15 14:08:59

DTOs, when should they be used?

There is a microservice, CRUD for all entities. Under the hood, it operates the database, cache and other things. Is synchronous REST running over HTTP/1.1

Requests and responses for all entities are the same. Only the entity model differs.

That is, of the form CreateRequest_TEntityModel_ , of course, with validation and an operation handler for each entity (the handler knows which entity its model belongs to) . operations before sending it to the microservice.

The question arises: should we create another DTO layer in this case to create requests to the microservice? Or can you use the same models that the microservice uses in the proxy?

The project may expand, but the basic operations are unlikely to be affected. That is, it would be possible to contact the microservice directly, but there will already be a dependency, so all such actions are done through a proxy.

I would like to hear a reasoned answer, thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
forced, 2022-04-17
@forced

In short, I answer my own question.
And the way they ask real questions ... so everyone subsides.
For microservices, common models are used, from which models of specific entities are INHERITED. Generic types allow you to change only the entity model, everything else is the same.
For requests to a microservice, a separate model, where the (concrete) microservice model IS owned by the proxy model. Ie composition.
The question can be considered closed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question