Refactored GsmDB

This commit is contained in:
2020-07-01 22:02:38 +01:00
parent 83b9c8b27c
commit 9774b85cae
7 changed files with 93 additions and 75 deletions
+28
View File
@@ -0,0 +1,28 @@
using Dapper;
using FireLance.Models;
using System.Collections.Generic;
using System.Linq;
namespace Gsm
{
public class GsmRO : GsmDB
{
public List<T> LoadRecords<T>(string select, string from, string column, string query, bool exactMatch)
{
string command = $"SELECT \"{select}\",*" +
$"FROM \"main\".\"{from}\"" +
$"WHERE \"{column}\"";
if (exactMatch == true)
{
command += $"LIKE \"{query}\"";
}
else
{
command += $"LIKE \"%{query}%\"";
}
return (List<T>) DBConnection.Query<T>(command, new DynamicParameters());
}
}
}