Need to speed up automapper…It takes 32 seconds to do 113 objects

后端 未结 7 2087
[愿得一人]
[愿得一人] 2021-01-30 09:25

Hi I have some major problems with auto mapper and it being slow. I am not sure how to speed it up.

I am using nhibernate,fluent nhibernate and asp.net mvc 3.0



        
7条回答
  •  不要未来只要你来
    2021-01-30 09:54

    A good tip is to optimize the configuration of AutoMapper, use Ignore for the properties of the ViewModels, and make the method call to validate the mappings "Mapper.AssertConfigurationIsValid()".

    Mapper.Initialize(cfg =>
            {
                cfg.ValidateInlineMaps = true;
                cfg.AllowNullCollections = false;
                cfg.AllowNullDestinationValues = true;                
                cfg.DisableConstructorMapping(); // <= In the case of my project, I do not use builders, I had a performance gain.
                cfg.AddProfile();
                cfg.AddProfile();
            });
    Mapper.AssertConfigurationIsValid();
    

提交回复
热议问题