Blog Bustin' .NET Beats

Recently did a load of view model classes which were basically flattened or otherwise simplified versions of an underlying DAL project which served up EntitySet objects – with all the heavy change tracking logic and navigation properties that involves.

Half ways through this, RSI was setting in, and I was getting really (really) bored of writing code like this.CustomerId = customer.CustomerId; – and when you get bored, you start making mistakes – and… well it was starting to look like a very long afternoon, let’s leave it at that.

So – I remembered someone once talking about AutoMapper being an excellent free tool for managing this kind of logic. So headed over to http://automapper.codeplex.com/ and downloaded the project – and after some very simple configuration steps I was able to map entire objects in one line of code.
AutoMapper at the most basic “out of the box” level will simply…

Ver la entrada original 155 palabras más

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: