public static void deleteBenchmark(Benchmark benchmark)
 {
     executeSql(""
         + "DELETE FROM "
             + "`" + tableName + "` "
         + "WHERE "
             + "`" + field_disciplineId + " = " + benchmark.Discipline.DisciplineId + " "
             + "AND `" + field_ageFrom + "` = " + benchmark.AgeFrom + " "
             + "AND `" + field_ageUntil + "` = " + benchmark.AgeUntil + " "
             + "AND `" + field_gender + "` = '" + benchmark.Gender + "' "
             + "AND `" + field_rank + "` = '" + benchmark.Rank + "' "
         + "LIMIT 1"
     );
 }
        public static List<Benchmark> getBenchmarksByDiscipline(Discipline discipline)
        {
            List<Dictionary<string, object>> results = querySql(""
                + "SELECT "
                    + "`" + field_ageFrom + "`, "
                    + "`" + field_ageUntil + "`, "
                    + "`" + field_gender + "`, "
                    + "`" + field_rank + "`, "
                    + "`" + field_benchmark + "` "
                + "FROM "
                    + "`" + tableName + "` "
                + "WHERE "
                    + "`" + field_disciplineId + "` = " + discipline.DisciplineId
            );

            List<Benchmark> benchmarks = new List<Benchmark>();

            foreach (var row in results)
            {
                Benchmark benchmark = new Benchmark(
                    discipline,
                    Convert.ToInt32(row[field_ageFrom]),
                    Convert.ToInt32(row[field_ageUntil]),
                    Convert.ToChar(row[field_gender]),
                    Convert.ToString(row[field_rank]),
                    Convert.ToDouble(row[field_benchmark])
                );

                benchmarks.Add(benchmark);
            }

            return benchmarks;
        }
 public static void updateBenchmark(Benchmark benchmark)
 {
     executeSql(""
         + "UPDATE "
             + "`" + tableName + "` "
         + "SET "
             + "`" + field_benchmark + "` = " + benchmark.BenchmarkValue + " "
         + "WHERE "
             + "`" + field_disciplineId + " = " + benchmark.Discipline.DisciplineId + " "
             + "AND `" + field_ageFrom + "` = " + benchmark.AgeFrom + " "
             + "AND `" + field_ageUntil + "` = " + benchmark.AgeUntil + " "
             + "AND `" + field_gender + "` = '" + benchmark.Gender + "' "
             + "AND `" + field_rank + "` = '" + benchmark.Rank + "'"
     );
 }
        public static Benchmark getBenchmarkByPrimaryKey(
            Discipline discipline,
            int ageFrom,
            int ageUntil,
            char gender,
            string rank
        )
        {
            Dictionary<string, object> result = querySingleSql(""
                + "SELECT "
                    + "`" + field_ageFrom + "`, "
                    + "`" + field_ageUntil + "`, "
                    + "`" + field_gender + "`, "
                    + "`" + field_rank + "`, "
                    + "`" + field_benchmark + "` "
                + "FROM "
                    + "`" + tableName + "` "
                + "WHERE "
                    + "`" + field_disciplineId + "` = " + discipline.DisciplineId + " "
                    + "AND `" + field_ageFrom + "` = " + ageFrom + " "
                    + "AND `" + field_ageUntil + "` = " + ageUntil + " "
                    + "AND `" + field_gender + "` = '" + gender + "' "
                    + "AND `" + field_rank + "` = '" + rank + "'"
            );

            if (result == null)
            {
                return null;
            }

            Benchmark benchmark = new Benchmark(
                discipline,
                Convert.ToInt32(result[field_ageFrom]),
                Convert.ToInt32(result[field_ageUntil]),
                Convert.ToChar(result[field_gender]),
                Convert.ToString(result[field_rank]),
                Convert.ToDouble(result[field_benchmark])
            );

            return benchmark;
        }