Reputation: 3173
I have got a common scenario: SL app and WCF service as data source.
I use DTOs for transferring business objects over the wire. I have an issue - Update entity. In the client form, I have a binded DTO and I send this to WCF. I want to know a nice way to update a real database entity by DTO data. In WCF, I use NHibernate for the DAL. My solution is getting the attached entity by id from the database and I copy all properties (with nested objects) from the DTO.
But I think it's not flexible or good. Can you advise me a better way?
Upvotes: 1
Views: 1602
Reputation: 1885
Like anything DTOs have pros & cons but when your DTOs are exactly the same as your Entities it can seem like a burden to do the property mapping manually.
Try looking at AutoMapper which should help you speed up the property mapping.
Upvotes: 1