Search code examples
c#dapperrowversion

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.

My object has...

public byte[] RowVersion { get; set; }

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

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

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

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?


Solution

  • 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

    Thanks for that.