views:

65

answers:

1

I'm using AutoMapper in a number of projects within my solution. These projects may be deployed independantly, across multiple servers.

In the documentation for AutoMapper it says:

If you're using the static Mapper method, configuration only needs to happen once per AppDomain. That means the best place to put the configuration code is in application startup, such as the Global.asax file for ASP.NET applications.

Whilst some of the projects will be ASP.net - most of these are class libraries / windows services.

Where should I be configuring my mappings in this case?

+1  A: 

The idea that it should only be required once per AppDomain stays the same, as far as I can tell. I always perform my mappings upon the initialization of the program itself. While I am not using AutoMapper I am using an IoC library (Windsor) which requires a mapping of sorts and this is done from my program.cs file. So when the application loads it performs the mapping and because the resolver is static and in a shared library it is available globally.

I don't know if this answers your question or not, but essentially every app has an entry point and if you need your mappings immediately after entry then the entry is the best place to put them.

joshlrogers