所以我有以下情况:
如您所见,某些字段为空,因此我想在插入记录之前检查表中是否已经存在goal该记录,我要插入的记录包含与表中已经可用的记录完全相同的结构。
这是我的代码:
public bool CheckGoalExist(Goal goal, Goal.GoalType type, int matchId)
{
using (MySqlConnection connection = new DBConnection().Connect())
{
using (MySqlCommand command = new MySqlCommand())
{
command.Connection = connection;
command.CommandText = "SELECT COUNT(*) FROM goal " +
"WHERE player_marker_id = @player_marker_id AND " +
"team_id = @team_id AND " +
"player_assist_id = @player_assist_id AND " +
"match_id = @match_id AND " +
"minute = @minute AND " +
"type = @type";
command.Parameters.AddWithValue("@team_id", goal.TeamId);
command.Parameters.AddWithValue("@player_marker_id", goal.MarkerPlayer.Id);
command.Parameters.AddWithValue("@player_assist_id", goal.AssistPlayer?.Id);
command.Parameters.AddWithValue("@match_id", matchId);
command.Parameters.AddWithValue("@minute", goal.Minute);
command.Parameters.AddWithValue("@type", GetGoalTypeId(type));
return Convert.ToBoolean(command.ExecuteScalar());
}
}
}
这将返回,false但值goal是这样的:
TeamId = 95
MarkerPlayer.Id = 122
AssistPlaer = null
matchId = 2564940
Minute = 82'
Type = 5
为什么返回false?
慕的地6264312
白衣非少年
元芳怎么了
相关分类