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

前端 未结 4 2079
北海茫月
北海茫月 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条回答
  •  生来不讨喜
    2020-12-09 03:53

    I would consider EF4 entities business models AND viewmodels rolled into one. They already implement PropertyChanged out of the box, for example. Partial classes can provide custom functionality if you need. Mirroring the entities with your own safety layer creates unnecessary work and maintenance, in my opinion.

    I'm a believer in separation of business logic and everything else. However in the case of EF4 the work is already done for you. Go nuts.

提交回复
热议问题