Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Where should I define my Custom Maps? #1250


User avatar
0
eu11111 created

I would like to implement some Custom Maps. Where would be the perfect place to do so? In my application module?


3 Answer(s)
  • User Avatar
    0
    david created

    This is what i do in my web module, you can do the same in your Application module:

    public static class AutoMapperWebConfiguration { public static void Configure() { ConfigureAdministrationMapping();

        }
    
        private static void ConfigureAdministrationMapping()
        {
            var input = Mapper.CreateMap<ServerViewModel, ServerInput>();
            var AppUserToUserMap = Mapper.CreateMap<UserListDto, AppUserViewModel>()
                .ForMember(dest => dest.AppID,
                           opts => opts.MapFrom(src => src.UserName));
        }
    
    }
    

    and in initialize method of the module, i call AutoMapperWebConfiguration.Configure();

    It works for me, i don't know if there is a more elegant way of achieving it

  • User Avatar
    0
    hikalkan created
    Support Team

    We generally do it Initialize or PostInitialize method of our Application module.

  • User Avatar
    0
    eu11111 created

    Thanks for the reply guys!