I'm using DTOs between my business and presentation layers and have some mapping code in the service that converts DTO <-> domain object. I'm currently allowing the PL to partially populate a DTO and send it to an Update service, which updates only the changed properties on the associated DO.
What's the usual way of dealing with non-nullable (value) types in partially populated DTOs? For nullable types I just check if the DTO value is null, and if not, set the corresponding value on the DO. But the non-nullables will always contain a value, which may or may not have been set by the PL.
I could:
- use free-form strings in the DTO for the notionally value-typed properties and convert to/from the value type
- make the PL call a service method to update the value properties rather than pass them via the DTO
- force the PL to always send a fully populated DTO to the Update service
None of those seems ideal: is there an option I'm missing? Or am I approaching this problem from the wrong angle?
If it's relevant, I'm using C# 4, WCF and ASP.NET MVC