- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 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;
帮助!
最佳答案
我对自动映射器进行了基准测试。一个 2.0GHz Xeon 的单核能够在一个小物体上每秒处理 85,000 张 map (3 个属性)。它比手动复制属性慢 60 倍。如果您愿意,我可以为您设置其他值的基准。
关于c# - Automapper 在映射 1400 条记录时运行速度极慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4131720/
我正在尝试在两个对象列表之间进行映射。源类型具有类型为 A 的复杂属性。 ;目标类型是类型 A 的扁平子集加上源类型中的附加标量属性。 public class A { public int
Automapper 是否可以将平面对象映射到复杂的对象图? Mapper.CreateMap() 将 PersonDto.BirthCertificateFatherName 映射到 Person
我有类似 this. 的问题但是这个答案对我不起作用。 我正在做一个小项目。我有两个域模型(Post,Source): public class Post { public Post()
假设我在“消息”类上有一个“评论”属性。我还有 2 个类属性,它们具有“Body”属性。如果该类设置了任一类属性,我希望 AutoMapper 将 Body 属性投影到模型的 comment 属性中,
我是 AutoMapper 的新手,有一个我正在尝试解决的问题。 如果我有这样的源类: public class Membership { public int MembershipId {
我有一个场景,我想忽略基类中定义的类的某些属性。 我有一个这样的初始映射 Mapper.CreateMap() .Include()
如何覆盖 AutoMapper 用于给定属性的类型转换器? 例如,如果我有: public class Foo { public string Name { get; set; } } pub
我正在尝试使用 AutoMapper 将三个实体模型映射到一个 View 模型中。最终输出应该是一个递归类别树,其中包含类别中的产品。类别树正在运行,但 View 模型的 Products 属性为 n
我有一个 Student目的: public class Student { public int Id { get; set; } public string FirstName {
我有一个复杂的对象,如: public class BusinessUnit { public TradingDesk TradingDesk { get; } pub
假设我有这个类: public class Account { public int AccountID { get; set; } public Enterprise Enterpr
从概念上我发现 Automapper 非常有趣。然而,我正试图在上面烧伤(或加热)我的手指。有人可以帮我开始吗?我还不明白我可以从哪里开始。我会喜欢从头开始写一些代码(而不是使用其他人的样本)然后去做
我一直在尝试创建一个自动映射器自定义值解析器,但我似乎错过了一些设置步骤,因为它似乎永远找不到 public abstract class ValueResolver : IValueResolve
我正在尝试让 AutoMapper 为我们在 View 模型上本地化所有 DateTime 属性。我们在系统中的任何地方都使用 UTC 并将所有内容以 UTC 存储在数据库中,但我们希望自动将其转换为
我知道是 AutoMapper而不是 AutoMerge(r),而是…… 我已经开始使用 AutoMapper 并且需要映射 A -> B,并从 C 添加一些属性,以便 B 成为一种 A + C 的平
鉴于这些类,我如何映射它们的字典? public class TestClass { public string Name { get; set; } } public class TestC
我想自定义 AutoMapper 转换类型的方式,而不丢失 AutoMapper 已实现的功能。 我可以创建一个自定义 ITypeConverter实例,但我不知道如何调用默认行为。 Mapper.C
从存储过程返回的数据有 3 列重复数据: Name | Address | PhoneNumber | UniqueCol1 | UniqueCol2 理想情况下,我希望我的模型通过仅存储一次值并收集
当我使用 List 属性映射对象时,默认情况下 Automapper 会将目标对象的 list 属性设置为源对象的实例。 有没有办法让自动映射器创建一个新列表并复制项目但不复制列表实例? 我希望通过以
如果我有这组源类怎么办: namespace Source { class CA { public CB B { get; set; } } class
我是一名优秀的程序员,十分优秀!