private void Delete(Prediction prediction) { using var command = _connection.CreateCommand(); command.Connection = _connection; command.CommandText = $"delete from {Prediction.GetTableName()} " + $"where {Prediction.GetZodiacColumnName()} = :zodiac_id " + $"and {Prediction.GetTimeIntervalColumnName()} = :interval_id;"; command.Parameters.AddWithValue("zodiac_id", prediction.Zodiac.Id); command.Parameters.AddWithValue("interval_id", prediction.TimeInterval.Id); Console.WriteLine("Execute SQL: " + command.CommandText); command.ExecuteNonQuery(); }
public void SaveOrUpdate(Prediction prediction) { if (IsPredictionAlreadySaved(prediction)) { Update(prediction); } else { using var command = _connection.CreateCommand(); command.Connection = _connection; command.CommandText = $"insert into {Prediction.GetTableName()}({Prediction.GetZodiacColumnName()}, {Prediction.GetTimeIntervalColumnName()}, {Prediction.GetTextColumnName()}) " + "values (:zodiac_id, :interval_id, :text);"; command.Parameters.AddWithValue("zodiac_id", prediction.Zodiac.Id); command.Parameters.AddWithValue("interval_id", prediction.TimeInterval.Id); command.Parameters.AddWithValue("text", prediction.Text); Console.WriteLine("Execute SQL: " + command.CommandText); command.ExecuteNonQuery(); } }
private SQLiteDataReader GetPredictionDataReader(Zodiac zodiac, TimeInterval timeInterval) { using var command = _connection.CreateCommand(); command.Connection = _connection; command.CommandText = $"select {Prediction.GetZodiacColumnName()}, {Prediction.GetTimeIntervalColumnName()}, {Prediction.GetTextColumnName()} from {Prediction.GetTableName()} " + $"where {Prediction.GetZodiacColumnName()} = :zodiac_id " + $"and {Prediction.GetTimeIntervalColumnName()} = :interval_id;"; command.Parameters.AddWithValue("zodiac_id", zodiac.Id); command.Parameters.AddWithValue("interval_id", timeInterval.Id); Console.WriteLine("Execute SQL: " + command.CommandText); return(command.ExecuteReader()); }