Like everything in design, it depends on your needs.
- If you need to often see and bind to child properties, and you want to make it as easy as possible for developers to use your DTOs, you may want to use explicit factory methods to give you fully expanded child properties.
- If you want simplicity of code, do not expand the properties of the foreign key and just let the developers get the child of the object / collection that they want by key if necessary.
There may be problems in recursion; Do you also extend all the foreign key properties of the Department object? What if there is a link to another EmployeeDTO in the department subclass?
Microsoft Entity Framework, as well as other popular business objects, process this concept with lazy loading - they only retrieve the full extended child property if it is called by code. This is probably the most flexible solution, but has a small overhead / delay, since child properties cannot be selected in the same database call as the parent. This, of course, is not a pure DTO.
source share