سؤال

Is there any possibility to add logging (like nlog) to automapper map method ?

I will really want to have logged info about all mappings between objects.

Thanks

هل كانت مفيدة؟

المحلول

You can use the BeforeMap event:

Mapper.CreateMap<SourceType, DestinationType>().BeforeMap((src, dst) =>
{
     SomeStaticLogger.DebugFormat("Mapping stuff from {0} to {1}", src, dst);
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top