mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-20 21:55:03 -04:00
Swap to dapper and system.text.json for database backend
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Datastore;
|
||||
@@ -16,27 +15,16 @@ namespace NzbDrone.Core.Test.Framework
|
||||
|
||||
public class DirectDataMapper : IDirectDataMapper
|
||||
{
|
||||
private readonly DbProviderFactory _providerFactory;
|
||||
private readonly string _connectionString;
|
||||
private readonly IDatabase _database;
|
||||
|
||||
public DirectDataMapper(IDatabase database)
|
||||
{
|
||||
var dataMapper = database.GetDataMapper();
|
||||
_providerFactory = dataMapper.ProviderFactory;
|
||||
_connectionString = dataMapper.ConnectionString;
|
||||
_database = database;
|
||||
}
|
||||
|
||||
private DbConnection OpenConnection()
|
||||
{
|
||||
var connection = _providerFactory.CreateConnection();
|
||||
connection.ConnectionString = _connectionString;
|
||||
connection.Open();
|
||||
return connection;
|
||||
}
|
||||
|
||||
public DataTable GetDataTable(string sql)
|
||||
{
|
||||
using (var connection = OpenConnection())
|
||||
using (var connection = _database.OpenConnection())
|
||||
{
|
||||
using (var cmd = connection.CreateCommand())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user