Based on some code I am working with this appears to be the case. I couldn't find anything in the dapper documentation that explicitly said that it won't work with members that have custom get/set logic, but I did see this example:
根据我正在处理的一些代码,似乎是这样的。我在dapper文档中找不到任何明确说明它不能与具有自定义get/set逻辑的成员一起工作的东西,但是我确实看到了这个例子:
public class Dog
{
public int? Age { get; set; }
public Guid Id { get; set; }
public string Name { get; set; }
public float? Weight { get; set; }
public int IgnoredProperty { get { return 1; } } //red flag?
}
It seems like the fact that the one member that has custom get behavior is prefixed with Ignored
might suggest that Dapper will not try to populate these values. Is this true? Is this in the documentation and I just overlooked it?
看起来有一个自定义get行为的成员以被忽略为前缀,这可能表明Dapper不会尝试填充这些值。这是真的吗?这是文档里的吗?
1 个解决方案
#1
6
The reason dapper will ignore that one is that it doesn't have a setter. It doesn't care how your properties are implemented internally, but it needs a setter to use a property (although the setter doesn't have to be public).
dapper会忽略这一点的原因是它没有setter。它并不关心如何在内部实现属性,但是它需要一个setter来使用属性(尽管setter不一定是公共的)。
It can also use fields, as an aside.
它还可以使用字段作为旁白。
#1
6
The reason dapper will ignore that one is that it doesn't have a setter. It doesn't care how your properties are implemented internally, but it needs a setter to use a property (although the setter doesn't have to be public).
dapper会忽略这一点的原因是它没有setter。它并不关心如何在内部实现属性,但是它需要一个setter来使用属性(尽管setter不一定是公共的)。
It can also use fields, as an aside.
它还可以使用字段作为旁白。