Automatic Mappings with AutoMapper
Introduction Dispite recent announcements by Jimmy Bogard , I'm still using AutoMapper . Maybe it's because I'm used to it and I think it has great features - like mapping LINQ expressions - anyway, I'm sticking to it, for the time being! A couple things, though, I feel are missing: The ability to automatically map types Dependency injection (DI) of services into Profile classes So I set out to make these both work! Fortunately, AutoMapper provides many extension points that we can hook to in order to do what we want. So, I'm going to talk a bit about these topics. In a nutshell, the problem I am to solve is: automatically map types from one assembly into the types in another one, of course, using only conventions. My approach was, use a custom mapper profile ( Profile ) to go through all types in the source assembly, find out the corresponding types in the target assembly, and add them to the maps. AutoMapper and Dependency Injection First things first. ...