Where to place DTO <==> Entity translator in WCF service?

前端 未结 2 1928
北海茫月
北海茫月 2021-01-26 19:13

I have the following design : My Design My Design http://s15.postimg.org/3zha8rzqh/Design_Idea.png

I will have a class called \'ProductDTO\' in my service layer<

2条回答
  •  星月不相逢
    2021-01-26 19:18

    It seems your confusion may stem from assuming the Product class in your data layer is actually the Product entity. Generally in domain driver design, your business entities live-in/are the business logic layer. Usually these class are "ignorant" of persistence which is the responsibility of the data access layer (typically using an object-relational mapper framework).

    In practice, your service will require references to both to the domain model (business layer) and the data access layer to perform useful work. Both the WCF service code and the data access layer should depend on the domain model but the domain model should not have dependencies on either the data access layer or the WCF service code.

提交回复
热议问题