Hangfire Merge Command Error

368 Views Asked by At

I am trying to run Hangfire with SQL Server 2005 which does not have datetime2 data type so I found this discussion very helpful. That fixed one problem but it opened another. Now I get the error:

SqlMapper.cs not found. An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code. Incorrect syntax near 'merge'.

I found source code for SqlMapper.cs on GitHub. The Dapper.1.38 package is the package I added to my project. Even so, I get a message that the source file is different from when the module was built.

I did some debugging anyway and was able to find the SQL command that is causing the exception. It is this:

merge HangFire.Server as Target 
using (VALUES (@id, @data, @heartbeat)) as Source (Id, Data, Heartbeat) 
on Target.Id = Source.Id 
when matched then 
update set Data = Source.Data, LastHeartbeat = Source.Heartbeat 
when not matched then 
insert (Id, Data, LastHeartbeat) values (Source.Id, Source.Data, Source.Heartbeat);

The merge command syntax may not be compatible with SQL Server 2005 but I have not been able to isolate the reason for the exception. I suspect the VALUES clause. Any help would be appreciated.

0

There are 0 best solutions below