Ваши комментарии

Well I think there are better ways to iterate over the postmodel composition elements by the means of an iterator or tree traversal method, like this: https://stackoverflow.com/a/30779962/1608705. This will remove iteration in the visitor class. 

This will however make it harder to connect child-parent relations in the resulting database models. I could keep track of relations by having a dictionary<original, mapped>, but it feels like that will make the solution more complex.

For my other question "Does casting inside the visit methods break the "program to an interface" design rule?". I think it does and I think the work around is creating another visitor or strategy for adding children to an entity.

Do you have a preferred method for mapping an entity tree to DTO's? 



Сервис поддержки клиентов работает на платформе UserEcho