我正在使用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