Log page now uses EF for faster runtime queries.

This commit is contained in:
kay.one 2011-11-22 21:58:26 -08:00
commit c6716f2425
49 changed files with 14898 additions and 555 deletions

View file

@ -1,5 +1,10 @@
using System;
using System.Data.Common;
using System.Data.EntityClient;
using System.Data.SqlServerCe;
using MvcMiniProfiler;
using NzbDrone.Common;
using NzbDrone.Core.Instrumentation;
using PetaPoco;
namespace NzbDrone.Core.Datastore
@ -30,7 +35,7 @@ namespace NzbDrone.Core.Datastore
{
get
{
return GetConnectionString(_enviromentProvider.GetLogDbFileDbFile());
return GetConnectionString(_enviromentProvider.GetLogDbFileDbFile());
}
}
@ -50,11 +55,18 @@ namespace NzbDrone.Core.Datastore
return GetPetaPocoDb(LogConnectionString, profiled);
}
public LogDbContext GetLogEfContext()
{
return GetLogDbContext(LogConnectionString);
}
public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
{
MigrationsHelper.Run(connectionString, true);
var factory = new PetaDbProviderFactory
var factory = new DbProviderFactory
{
IsProfiled = profiled
};
@ -68,5 +80,12 @@ namespace NzbDrone.Core.Datastore
return db;
}
public static LogDbContext GetLogDbContext(string connectionString)
{
MigrationsHelper.Run(connectionString, true);
DbConnection connection = new SqlCeConnection(connectionString);
return new LogDbContext(connection);
}
}
}