views:

86

answers:

4

Does anyone know of a good (read: quick to code) method for converting DTOs to View Models or mapping DTO members to View Model members? Lately I've been finding myself writing many conversion and helper methods but this is a very arduous and tedious task. Moreover, it will often needs to be done twice (DTO -> View Model, View Model -> DTO).

Is there a methodology, technique, or technology which would allow me to do this more quickly and efficiently?

+2  A: 

Have a look at Automapper. It is an open source project that addresses exactly the problem you are having.

David Hall
A: 

As suggested by David, Automapper is highly flexible. If you have simple mapping need, check out the object mapping feature of Fasterflect, a library I co-authored. It offers very high performance (use CIL generation in the backend, instead of reflection) and is very easy to use.

Buu Nguyen
A: 

I found Otis Mapper better than AutoMapper , which facilitates mapping a collection of entities to DTO collection .

Please find the link below.

Otis

Hope this helps.

Thanks , Vijay

vijaysylvester
A: 

I see automapper as the best solution for DTO Mapping

CrazyBoy123