'What should I use if I need the result of overriding Entity in my service?

In my project rules, so far, the service only needs to return an Entity.

And the controller that received the Entity selects only the necessary information, creates a DTO and returns it to the View.

Haven't had any problems so far.

But now we have a problem.

There is a task in my service that retrieves user information and returns it after conversion.

In other words, the data type of the Entity I first looked up and the object I need are no longer the same.

easily, If I got an int value of "12", it means that I should return it as a String value of "OneTwo".

Now I need an object with new fields that Entity doesn't have.

At this point, what should I return from the service to the controller?

I thought of how to create a DTO in a service and how to create a new Model object that is neither a DTO nor an Entity.

Is there a better way?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source