I was scrolling through the MySQL connector code for .NET Core.
I saw the following code:
public async Task DeleteAsync
{
var cmd = Db.Connection.CreateCommand() as MySqlCommand;
cmd.CommandText = @"DELETE FROM `BlogPost` WHERE `Id` = @id;";
BindId(cmd);
await cmd.ExecuteNonQueryAsync();
}
private void BindId(MySqlCommand cmd)
{
cmd.Parameters.Add(new MySqlParameter
{
ParameterName = "@id",
DbType = DbType.Int32,
Value = Id,
});
}
Wouldn't this cause the method call
await cmd.ExecuteNonQueryAsync();
to be parameterless?
Full code on https://mysql-net.github.io/MySqlConnector/tutorials/net-core-mvc/