35 lines
957 B
C#
35 lines
957 B
C#
using Dapper;
|
|
using GSMParser.Inferfaces;
|
|
using Microsoft.Data.Sqlite;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Gsm
|
|
{
|
|
public class GsmRO : IGsmSqliteDBConnection
|
|
{
|
|
public SqliteConnection Database { get; private set; }
|
|
public void SetDatabaseInstance(SqliteConnection db)
|
|
{
|
|
Database = db;
|
|
}
|
|
|
|
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>) Database.Query<T>(command, new DynamicParameters());
|
|
}
|
|
}
|
|
}
|