Best Practices For Mapping DTO to Domain Object?

前端 未结 11 1367
执念已碎
执念已碎 2020-11-28 19:43

I\'ve seen a lot of questions related to mapping DTOs to Domain Objects, but I didn\'t feel they answered my question. I\'ve used many methods before and have my own opinio

11条回答
  •  星月不相逢
    2020-11-28 20:14

    We can use Factory, Memento, and Builder pattern for that. Factory hide the details on how to create instance of domain model from DTO. Memento will take care the serialization/deserialization of the domain model to/from DTO and can even access private members. The Builder will allows mapping from DTO to domain with fluent interface.

提交回复
热议问题