Home > OS >  How can I represent entity inheiritance as DTO if I want to use this DTO in service layer
How can I represent entity inheiritance as DTO if I want to use this DTO in service layer

Time:11-12

Let's say I am having inheritance in my entities like: Animal - parent Childs: Cat, Dog

I would like to use DTOs in my service layer and I wonder how can I represent the inheritance above as DTO? For example, I had a method like this in the service before using DTO: Animal add(Animal animal). I would like to be something like this: AnimalDTO add(AnimalDTO team)

CodePudding user response:

That is perfectly possible, just do it as you did for the entities.

  • Related