What is the best practice for sending data to the client: POCO or DTO?

前端 未结 4 2072
北海茫月
北海茫月 2020-12-09 03:25

I\'m starting a project using EF 4 and POCO.

What is the best practice for sending data to the client ? Should I send the POCO or I should have a DTO instead?

4条回答
  •  -上瘾入骨i
    2020-12-09 03:50

    I have a bit different opinion from above opinions. I believe DTO or ViewModel is still needed for out side of the Server Layer. In real world application, there is a few view layer which only need one Domain Object, that is, almost every views need multiple Domain Objects. And all those Domain Objects are wrapped in one DTO or ViewModel Class. This is why I insist DTO or ViewModel is still needed even though they are POCO.

提交回复
热议问题