I'm trying to figure out what is the best way to update a polymorphic child entity inside an aggregate root. For reference, let's say I have a ShippingContainer
root entity that stores Cargo
objects; there are many types of Cargo
objects, for example, BigCargo
, HazardousCargo
, etc., each with their own unique properties.
I was reading this question: Update an entity inside an aggregate
The answer to this question seems to indicate I should place the ChangeCargo
method on the ShippingContainer
object taking some kind of DTO parameters object. My question is whether or not this is still best practice when the object you are trying to update is polymorphic (do I now need a hierarchy of DTO objects mirroring the Cargo object types?), or should I be doing something else?