Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jakob Kristensen 36 posts 169 karma points
    Jun 27, 2017 @ 16:32
    Jakob Kristensen
    0

    Creating additional Automapper maps in umbraco

    Helloooo umbraco

    Is there any way to register additional maps within umbraco, currently im struggling to get my mappers to work, first i initialize them on application starting.

        protected override void OnApplicationStarting(object sender, EventArgs e)
        {
    
            base.OnApplicationStarting(sender, e);
            GlobalConfiguration.Configure(WebApiConfig.Register);
    
            AutoMapperWebConfiguration.Configure();
    
    
        }
        public static class AutoMapperWebConfiguration
        {
            public static void Configure()
            {
                Mapper.Initialize(cfg =>
                {
                    cfg.AddProfile(new UserProfile());
                });
            }
        }
    
        public class UserProfile : Profile
        {
            protected override void Configure()
            {
                Mapper.CreateMap<Case, CaseDTO>();
            }
        }
    

    Any Ideas why this is failing to register i had the idea umbraco maybe was overwriting my maps.

    Thanks in advance :)

  • Yakov Lebski 594 posts 2350 karma points
    Jun 28, 2017 @ 19:50
    Yakov Lebski
    101

    I do it on OnApplicationInitialized (implementing IApplicationEventHandler) What kind of error did you have?

  • Jakob Kristensen 36 posts 169 karma points
    Jul 06, 2017 @ 11:01
    Jakob Kristensen
    0

    Thank you for the answer, i ended up fixing it with onapplicationStarted, i guess automapper wasnt initialized yet, so this would be the correct answer, applying high fives :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies