Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object to Object Mapping Utility

I like to cleanly separate public and domain objects (so, nHibernate isn't going to help here) from each other which ends up forcing me to write a lot of code to map one object to another. What tools/plugins are out there to take the tedium of having to do manually do this mapping in .NET?m Whenever I Google this, it thinks I'm wanting to do ORM, which is not what I'm looking for. Thanks!

EDIT 19:33CST: OK, I wrote a very basic application (very quickly written code) that demonstrates what I'm looking for. I'm just wondering if there is a VS plugin that will do this for me.

VS2008 Solution

like image 541
Wayne Hartman Avatar asked May 15 '09 20:05

Wayne Hartman


2 Answers

You might want to give AutoMapper a try. It sounds like what you're looking for.

like image 98
Kevin Pang Avatar answered Oct 17 '22 00:10

Kevin Pang


So, seemingly dissatisfied with a runtime solution, I have written a small utility that will create the mappings in code. You can download the source below and write better error handling, etc., etc. I'd appreciate any cool modifications you make, this was made in haste, but works. Please respect that the code is being released under the LGPL.

Object To Object Mapping Utility Source Code

UPDATE 23 JUN 2009: I made some updates to the code that cleaned it up (a little bit) and also added the ability to save a mapping to a file so that you can later modify it.

like image 34
Wayne Hartman Avatar answered Oct 17 '22 02:10

Wayne Hartman