I have worked on several distributed client/server projects recently, and one pain point that we always run into is translating the DTO objects into our entities and vice-versa. I was wondering if anyone has a "simple" solution to this time sink?
One thing I thought about was coming up with some sort of translation using reflection...I guess you'd have to make sure your property names were exactly the same on each side of the wire - but seems like it might work.
Just looking for a way to avoid some of this time sink in my development.
Thanks!!
Entities represent the persistence model of an application and they are always internal to the application. On the other hand, DTOs (Data Transfer Objects) represent the models which the application exposes with the outside world.
IF the entity and DTO are exactly the same, and IF you can guarantee that there will never be any changes to the data model; then you are correct that you can omit the DTO. But the thing is that you can never guarantee that the data model will never change.
I have been using AutoMapper recently, and it works like a charm.
of getting/setting properties by hand! Have you tried this: http://dozer.sourceforge.net/.
A flexible and configurable framework for translating bean to bean. Might help!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With