Adding
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
|
||||
|
||||
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities
|
||||
{
|
||||
public class CoreDbExecution : ICoreDbExecution
|
||||
{
|
||||
private readonly IDbConnection _dbConnection;
|
||||
private readonly CoreConfiguration _coreConfiguration;
|
||||
private readonly CoreDbConfiguration _coreDbConfiguration;
|
||||
|
||||
public CoreDbExecution(IDbConnection dbConnection,
|
||||
CoreConfiguration coreConfiguration)
|
||||
{
|
||||
_coreConfiguration = coreConfiguration;
|
||||
_coreDbConfiguration = _coreConfiguration.CoreDbConfiguration;
|
||||
_dbConnection = dbConnection;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<T>> ExecuteQuery<T>(string query)
|
||||
{
|
||||
_dbConnection.Open();
|
||||
var result = await _dbConnection.QueryAsync<T>(query);
|
||||
_dbConnection.Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<T>> ExecuteQuery<T, P>(string query, P parameters)
|
||||
{
|
||||
_dbConnection.Open();
|
||||
var result = await _dbConnection.QueryAsync<T>(query, parameters);
|
||||
_dbConnection.Close();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities
|
||||
{
|
||||
public interface ICoreDbExecution
|
||||
{
|
||||
Task<IEnumerable<T>> ExecuteQuery<T>(string query);
|
||||
Task<IEnumerable<T>> ExecuteQuery<T, P>(string query, P parameters);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user