小编Rya*_*yan的帖子

自动映射在映射1400记录时运行速度极慢

我正在使用AUtomapper,但我印象非常深刻,我有一个带有许多嵌套集合的复杂对象.我正在使用Telerik OpenAccess,它会快速返回1400条记录,但是当我将它传递给Automapper时,它会慢慢变成荒谬的爬行.这是我的代码供参考:

        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;
Run Code Online (Sandbox Code Playgroud)

救命!

c# asp.net c#-4.0

11
推荐指数
4
解决办法
6774
查看次数

标签 统计

asp.net ×1

c# ×1

c#-4.0 ×1