Dapper を使用して行を更新しようとしていますが、更新ステートメントでパラメーターを指定するとエラーが発生します
An exception of type 'System.InvalidOperationException' occurred in IBM.Data.DB2.iSeries.dll but was not handled in user code
Additional information: Not enough parameters specified. The command
requires 3 parameter(s), but only 0 parameter(s) exist in the
parameter collection.
リポジトリ.cs
public void Update(Movie movie)
{
var sql = "UPDATE myDB.movies set title=?, genre=? where Id=?";
db.Execute(sql, new
{ movie.Title,
movie.Genre,
movie.ID
});
}
Movie.cs
public class Movie
{
public int ID { get; set; }
[Required]
public string Title { get; set; }
[Required]
[Display(Name="Release Date")]
[DisplayFormat(DataFormatString="{0:dd/MM/yyyy}", ApplyFormatInEditMode=true)]
public DateTime ReleaseDate { get; set; }
[Required]
public string Genre { get; set; }
public decimal Price { get; set; }
}
iDB2Connection
IBM ISeries データベースへのアクセスに使用しています。