My question is fairly simple and already asked in the title.
Here’s the context: I’ve got a domain with entities and repositories. The result of a query is mapped into DTO and sent to the GUI.
The GUI is implemented with WPF and for the mapping, I need classes that implement INotifyPropertyChanged.
My first idea is to have DTO that implement this interface because I foresee a lot of work to map again my DTO into items that implement INotifyPropertyChanged.
Is it a good practice? Has it pitfalls I haven’t seen? What is the “official” good practice for this situation?
DTOs are supposed to be very simple, lightweight, data transfer objects. Because of this, I wouldn’t implement anything on them other than their data. Also, I believe if serializing the class to/from a WCF server, the properties need to all be public, so you can’t make things like the Id read-only
I would create
Modelclasses that implementINotifyPropertyChangedandIDataErrorInfofor property changed notification and validation purposes, and have them accept a DTO in the Constructor. Using something like AutoMapper will make mapping a DTO to a Model pretty simple