Files
FireLance/GSMParser/QueryBuilder.cs

48 lines
1.1 KiB
C#

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);
}
public static string GameById(string id)
{
return NewQueryFromCommand("GameName", "GameEntry", "id", id, true, true);
}
public static string DirectoryById(string id)
{
return NewQueryFromCommand("Path", "Directories", "GameID", id, true, true);
}
}