I'm attempting to use Dapper to update the records found in one of my Database tables. The table itself is described as below.
ID int
AppId nvarchar(MAX)
Created datetime2(7)
Updated datetime2(7)
Data nvarchar(MAX)
The object going into the table is defined in C# code as follows:
public class Schema
{
public int ID { get; set; }
public string AppId { get; set; }
public DateTime Created { get; set; }
public DateTime Updated { get; set; }
public string Data { get; set; }
}
But when I execute the code below I get a NotSupportedException: The member newSchema of type Schema cannot be used as a parameter value
public int UpdateSchema(Schema newSchema, int idToUpdate)
{
var sql = "UPDATE Schemas " +
"SET schema = @newSchema " +
"WHERE ID = @idToUpdate";
var result = _connection.Execute(sql, new {newSchema, idToUpdate});
return result;
}
Why exactly is this happening and what can I do to prevent it? I know that my Schema
class is compitable with my database table as when I attempt to create new Schema records in the table it executes my query without any issues.
Comments
Post a Comment