I'm trying to use Dapper to do simple CRUD operations to a SQLite database, but I'm having trouble because the compiler is accusing a error that I simply dont know how to fix.
The error in questions is in the "conn.Execute..." line and it says:
C#: Several methods are applicable to '(string, DBManager.(anonymous))': 'Dapper.SqlMapper.Execute(System.Data.IDbConnection, string, , System.Data.IDbTransaction, int?, System.Data.CommandType?)' and 'Dapper.SqlMapper.Execute(System.Data.IDbConnection, string, , System.Data.IDbTransaction, int?, System.Data.CommandType?)' DBManager.cs
Below is my code, I try to put here everything that I think will be useful to look at but without putting too much.
using System;
using System.Linq;
using Dapper;
public bool Insert(SchedulerHistory record)
{
int res = -1;
if (record == null)
return false;
try
{
//var db = new SQLDatabase();
string sqlquery = "insert into SchedulerHistory (JobId, NextJob, LastJob, ExecuteOnStart) Values (@JobId, @NextJob, @LastJob, @ExecuteOnStart);";
using (var conn = new System.Data.SQLite.SQLiteConnection(m_connString))
{
conn.Open();
conn.Execute (sqlquery, new { JobId = record.JobId, NextJob = `record.NextJob, LastJob = record.LastJob, ExecuteOnStart = record.ExecuteOnStart });`
return (res > 0);
}
}
catch (Exception ex)
{
LogWriter.Error(ex);
return false;
}
}
Note that the "using Dapper;" is marked as not used by VS2012, and the method its not done, I was adapting from what I have previously done because I thought dapper would be helpful.