Using SQL Server 2014.
Given table with rowversion column, other table to join with and a select like this:
CREATE TABLE dbo.FooTable( [Id] [int] IDENTITY(1,1) NOT NULL, [RowVersion] [rowversion] NULL, CONSTRAINT [PK_FooTable] PRIMARY KEY CLUSTERED ( [Id] ASC )) CREATE TABLE dbo.BarTable( [Id] [int] IDENTITY(1,1) NOT NULL CONSTRAINT [PK_BarTable] PRIMARY KEY CLUSTERED ( [Id] ASC )) Insert into BarTable default values GO SELECT * FROM FooTable ft FULL OUTER JOIN BarTable bt on ft.Id = Bt.Id
Result of select is:
Id RowVersion Id NULL 0x 1
Where there was no match with BarTable the RowVersion column is not null, but 0x.
This confuses Dapper, which we use to deserialize result on app server, into thinking, it should construct an object for FooTable part of row - an invalid one, containing just an empty byte array.
Is there any reason for this rather unexpected behaviour?
Are there any smarter solutions than translating the value back to null using CASE in the sql statement or dealing with it in application code?