In Ward's article "Breeze Server: Have Your Way ":
A typical business application has at least 200 domain model types. 90 +% of the time when the form of data that I send over the wire is the same as the form of the object in my business model.
...
When the form of the client object does not align well with the form of the business object on the server side, I can switch to DTO for this special case.
It hits a nail right on the head for our application, but what's the best way to switch only some objects for DTO?
For example, our custom object contains sensitive properties that should not be exposed to the client. It also has associated data that is retrieved from other systems and returned to the client, which ideally should simply be additional properties on the user's client objects. The user seems like the perfect candidate for switching to DTO.
If the user was an isolated object, this might be easier, but the problem is that the user is referenced mostly everywhere in the model. For example, almost every object has a CreatedBy property.
Is there a way to switch the User object for a user DTO in the model? For all other model objects that reference users, we still need to be able to load them with advanced user properties, query them for these user properties, and save them with changes to these user properties.
I'm not sure how to do this, except creating a large DTO model that is 95% identical to the entity model and has some code / mapping structure between them. But, as Ward says in this post , βI donβt like DTO for every type, itβs redundant, which can ruin the performance.β
Joe daley
source share