我正在使用Automapper,但我对它印象非常深刻,但我有一个复杂的对象,其中包含许多嵌套集合。我使用的是Telerik OpenAccess,它可以快速返回1400条记录,但是当我将它传递给Automapper时,它减慢到可笑的抓取。这里是我的代码供参考:Automapper在映射1400条记录时运行速度极其缓慢
List<DAL.Event> query = httpContext.Events.Where(e => e.Inactive != true && e.Event_Locations != null).ToList();
Mapper.CreateMap<DAL.Event, EventDTO>();
Mapper.CreateMap<DAL.Event_Association, EventAssociationDTO>();
Mapper.CreateMap<DAL.Event_ExecutingUnit, EventExecutingUnitDTO>();
Mapper.CreateMap<DAL.Event_Funding, EventFundingDTO>();
Mapper.CreateMap<DAL.Event_Location, EventLocationDTO>();
Mapper.CreateMap<DAL.Event_Objective, EventObjectiveDTO>();
Mapper.CreateMap<DAL.Event_OSR, EventOSRDTO>();
Mapper.CreateMap<DAL.Event_PaxBreakDown, EventPAXBreakDownDTO>();
Mapper.CreateMap<DAL.Event_RegionalConsideration, EventRegionalConsiderationDTO>();
Mapper.CreateMap<DAL.Event_ReviewStatus, EventReviewStatusDTO>();
Mapper.CreateMap<DAL.Event_SPCalendarClone, EventSPCalendarClonesDTO>();
Mapper.CreateMap<DAL.Event_Task, EventTasksDTO>();
Mapper.CreateMap<DAL.Event_TSO, EventTSOsDTO>();
Mapper.AssertConfigurationIsValid();
Mapper.AllowNullDestinationValues = true;
IList<EventDTO> result = Mapper.Map<List<DAL.Event>, List<EventDTO>>(query);
return result;
帮助!
哪个AutoMapper的版本您使用的? – 2010-11-09 08:35:44
这是什么荒谬的价值? – Kangkan 2010-11-09 08:47:14
您可能想要使用分析器(即dotTrace)来分析哪部分代码运行缓慢。 – 2010-11-09 08:54:57