无法使Dapper正确处理SQL RowVersion [英] Can't get Dapper to handle SQL RowVersion properly

查看:150
本文介绍了无法使Dapper正确处理SQL RowVersion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中添加了一个rowversion列,我正在尝试获取Dapper映射以在对象上正确填充它.

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.

我的对象有...

public byte[] RowVersion { get; set; }

我已经在查询中包含了RowVersion列,但是当我执行查询时.

And I have included the RowVersion column in my query but when I do a Query..

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

我传递给我的MyObject的RowVersion属性为null.

The MyObject that I get passed to me has a null for the RowVersion property.

如果我执行不带任何类型的Dapper Query(),则返回的动态具有正确值的预期RowVersion.

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.

有人能做到这一点吗?如果是的话,我在做什么错了?

Has anyone had this working and if so what am I doing wrong?

推荐答案

由于Panagiotis Kanavos的精神震撼,我得以解决此问题.我开始简化查询以使其能够发布,并意识到我将RowVersion列放置在select语句的错误位置,因此将其发送到AnotherObject而不是MyObject

I was able to resolve this thanks to the mental knock from 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

谢谢.

这篇关于无法使Dapper正确处理SQL RowVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆