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