mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
added Marr.Data.Mapping
This commit is contained in:
parent
4bb4faf626
commit
6dd56114e3
29 changed files with 208 additions and 229 deletions
|
@ -1,25 +1,21 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using ServiceStack.OrmLite;
|
||||
using ServiceStack.OrmLite.Sqlite;
|
||||
using Marr.Data;
|
||||
using Mono.Data.Sqlite;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public interface IDbFactory
|
||||
{
|
||||
IDbConnection Create(string dbPath = null);
|
||||
IDatabase Create(string dbPath = null);
|
||||
}
|
||||
|
||||
public class DbFactory : IDbFactory
|
||||
{
|
||||
private const string MemoryConnectionString = "Data Source=:memory:;Version=3;New=True;";
|
||||
|
||||
static DbFactory()
|
||||
{
|
||||
OrmLiteConfig.DialectProvider = new SqliteOrmLiteDialectProvider();
|
||||
}
|
||||
|
||||
public IDbConnection Create(string dbPath = null)
|
||||
public IDatabase Create(string dbPath = null)
|
||||
{
|
||||
var connectionString = MemoryConnectionString;
|
||||
|
||||
|
@ -29,16 +25,12 @@ namespace NzbDrone.Core.Datastore
|
|||
}
|
||||
|
||||
MigrationHelper.MigrateToLatest(connectionString, MigrationType.Main);
|
||||
|
||||
OrmLiteConfig.DialectProvider = new SqliteOrmLiteDialectProvider();
|
||||
var dbFactory = new OrmLiteConnectionFactory(connectionString);
|
||||
var connection = dbFactory.Open();
|
||||
|
||||
Migration.CreateTables(connection);
|
||||
|
||||
return connection;
|
||||
var dataMapper = new DataMapper(SqliteFactory.Instance, connectionString);
|
||||
return new Database(dataMapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private string GetConnectionString(string dbPath)
|
||||
{
|
||||
return String.Format("Data Source={0};Version=3;", dbPath);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue