From ae691811193fd3fba1a23108dd13ef4009b53abd Mon Sep 17 00:00:00 2001 From: Dunestorm Date: Sun, 28 Jun 2020 00:08:39 +0100 Subject: [PATCH] Massively simplified QueryBuilder --- GSMParser/QueryBuilder.cs | 45 +++++++++++---------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/GSMParser/QueryBuilder.cs b/GSMParser/QueryBuilder.cs index 9870678..e045d13 100644 --- a/GSMParser/QueryBuilder.cs +++ b/GSMParser/QueryBuilder.cs @@ -1,47 +1,26 @@ public static class QueryBuilder { - private static string NewQueryFromCommand(string select, string from, string where, string query, bool modalRecord, bool exactMatch) - { - string _query = string.Empty; - - _query += ($"SELECT \"{select}\""); - - if (modalRecord == true) - { - _query += ",* "; - } - else - { - _query += " "; - } - - _query += ($"FROM \"main\".\"{from}\"" + - $"WHERE \"{where}\" "); - - if (exactMatch == true) - { - _query += ($"LIKE '{query}'"); - } - else - { - _query += ($"LIKE '%{query}%'"); - } - - return _query; - } - public static string GameByName(string name) { - return NewQueryFromCommand("GameName", "GameEntry", "GameName", name, true, false); + return $"SELECT \"GameName\",*" + + $"FROM \"main\".\"GameEntry\"" + + $"WHERE \"GameName\"" + + $"LIKE \"%{name}%\""; } public static string GameById(string id) { - return NewQueryFromCommand("GameName", "GameEntry", "id", id, true, true); + return $"SELECT \"GameName\",*" + + $"FROM \"main\".\"GameEntry\"" + + $"WHERE \"id\"" + + $"LIKE \"{id}\""; } public static string DirectoryById(string id) { - return NewQueryFromCommand("Path", "Directories", "GameID", id, true, true); + return $"SELECT \"Path\",*" + + $"FROM \"main\".\"Directories\"" + + $"WHERE \"GameID\"" + + $"LIKE \"{id}\""; } }