简体   繁体   English

无法使Dapper正确处理SQL RowVersion

[英]Can't get Dapper to handle SQL RowVersion properly

I've got a rowversion column added to my database and I'm trying to get Dapper mapping to populate it properly on my object. 我在数据库中添加了一个rowversion列,并尝试获取Dapper映射以在对象上正确填充它。

My object has... 我的物件有...

public byte[] RowVersion { get; set; }

And I have included the RowVersion column in my query but when I do a Query.. 而且我在查询中包含了RowVersion列,但是当我执行查询时。

conn.Query<MyObject, AnotherObject, AnAdditionalObject>(...

The MyObject that I get passed to me has a null for the RowVersion property. 我传递给我的MyObject的RowVersion属性为null。

If I do a Dapper Query() without any type then the dynamic I get back has the expected RowVersion on it with the correct value. 如果我执行不带任何类型的Dapper Query(),则返回的动态具有正确值的预期RowVersion。

Has anyone had this working and if so what am I doing wrong? 有人进行过这项工作吗?如果是的话,我在做什么错呢?

I was able to resolve this thanks to the mental knock from Panagiotis Kanavos. 由于Panagiotis Kanavos的精神震撼,我得以解决此问题。 I started simplifying my query to be able to post it and realized that I had placed the RowVersion column in the incorrect place of my select statement so it was being sent to AnotherObject instead of MyObject 我开始简化查询以使其能够发布,并意识到我将RowVersion列放置在select语句的错误位置,因此将其发送到AnotherObject而不是MyObject

Thanks for that. 感谢那。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM