- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 AutoMapper 的投影方法与 Xamarin Sqlite 一起使用。我的代码如下所示:
var myList = conn.Table<SomeTable>()
.Where(w => w.ForeignKeyId == foreignKeyId)
.AsQueryable()
.ProjectTo<SomeTableDto>()
.ToList();
该代码在 Android 模拟器上运行,但在 iOS 模拟器上失败。 iOS 上的错误是:
System.NotImplementedException: The method or operation is not implemented.
堆栈跟踪的顶部如下。如果需要,我可以提供完整的堆栈跟踪,它很长。
at Microsoft.Scripting.Interpreter.LightCompiler.CompileMemberInitExpression (System.Linq.Expressions.Expression expr) [0x00000] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1532
at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush (System.Linq.Expressions.Expression expr) [0x002a7] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs:1660
未找到的方法是 ToList() 调用。为什么在 iOS 上找不到该方法?
我已经通过执行以下操作解决了该问题,但我很好奇为什么我的初始代码在 iOS 上不起作用。
var someTableList = conn.Table<SomeTable>()
.Where(w => w.ForeignKeyId == foreignKeyId)
.ToList();
var myDtoList = Mapper.Map<List<SomeTableDto>>(someTableList);
我使用的是 AutoMapper 5.1.1、Xamarin Forms 2.3.1 和 Sqlite-net-pcl 1.1.2。
最佳答案
我很确定问题出在 iOS 链接器上。我在以下位置发现了类似的问题:
https://github.com/AutoMapper/AutoMapper/issues/1542
https://github.com/AutoMapper/AutoMapper/issues/686
感谢@Krumelur 为我指明了 iOS 链接器的方向。如果有人能想到其他任何东西,请告诉我。
关于c# - 将 AutoMapper 与 Xamarin Sqlite 一起使用时未找到 ToList 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39476141/
我正在尝试在两个对象列表之间进行映射。源类型具有类型为 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
我是一名优秀的程序员,十分优秀!