WCF / Service Layer / Repository Layer: Returning DTO from Service layer? And creating ViewModel in Controller from the DTO returned
-
30-10-2019 - |
题
I would like some help on my current design. I have a WCF Service, behind the WCF service is a Service layer (http://martinfowler.com/eaaCatalog/serviceLayer.html) and repository layer.
So a client calls the WCF Service layer and the WCF Service layer (acting as a service layer) calls the repository layer.
The repository layer returns MODELS (Poco's) which represent the Database. Then the service layer i presume i need to convert the POCOS to DTO to transfer over the wire? Or should i just leave these as POCOs?
Once i have my given object on the serviice layer i return this to the client (ASP.NET MVC) whose controller is reponsible for mapping the object returned from the WCF Service into a VIEWMODEL.
I want to know i am doing this right i.e. Service layer and Repository layer behind WCF Service?
And controller in charge of creating a ViewModel from the actual model that is returned from the WCF Service.
Also i wonder if its really necessary to convert from the REAL models that the Repository would return to DTOs ready from returning from the WCF Service.
Any help really appreciated
没有正确的解决方案