mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-26 17:47:08 +00:00
Should fix the transaction issues in petapoco, we are getting to far petapoco master which I don't like.
This commit is contained in:
parent
9244a4e6ef
commit
8ce222a10c
2 changed files with 12 additions and 19 deletions
|
@ -74,11 +74,11 @@ private static void BindKernel()
|
||||||
Logger.Debug("Binding Ninject's Kernel");
|
Logger.Debug("Binding Ninject's Kernel");
|
||||||
_kernel = new StandardKernel();
|
_kernel = new StandardKernel();
|
||||||
|
|
||||||
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.MainConnectionString)).InRequestScope();
|
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.MainConnectionString)).InTransientScope();
|
||||||
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.MainConnectionString, false)).WhenInjectedInto<IJob>();
|
//_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.MainConnectionString, false)).WhenInjectedInto<IJob>();
|
||||||
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.MainConnectionString, false)).WhenInjectedInto<JobProvider>();
|
//_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.MainConnectionString, false)).WhenInjectedInto<JobProvider>();
|
||||||
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.LogConnectionString, false)).WhenInjectedInto<DatabaseTarget>().InSingletonScope();
|
//_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.LogConnectionString, false)).WhenInjectedInto<DatabaseTarget>().InSingletonScope();
|
||||||
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.LogConnectionString)).WhenInjectedInto<LogProvider>().InRequestScope();
|
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.LogConnectionString)).WhenInjectedInto<LogProvider>().InSingletonScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -342,7 +342,6 @@ public enum DBType
|
||||||
// Common initialization
|
// Common initialization
|
||||||
private void CommonConstruct()
|
private void CommonConstruct()
|
||||||
{
|
{
|
||||||
_transactionDepth = 0;
|
|
||||||
ForceDateTimesToUtc = true;
|
ForceDateTimesToUtc = true;
|
||||||
EnableAutoSelect = true;
|
EnableAutoSelect = true;
|
||||||
|
|
||||||
|
@ -407,6 +406,7 @@ public void CloseSharedConnection()
|
||||||
OnConnectionClosing(_sharedConnection);
|
OnConnectionClosing(_sharedConnection);
|
||||||
_sharedConnection.Dispose();
|
_sharedConnection.Dispose();
|
||||||
_sharedConnection = null;
|
_sharedConnection = null;
|
||||||
|
_transaction = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,16 +440,12 @@ public void BeginTransaction()
|
||||||
// matched by a call to AbortTransaction or CompleteTransaction
|
// matched by a call to AbortTransaction or CompleteTransaction
|
||||||
// Use `using (var scope=db.Transaction) { scope.Complete(); }` to ensure correct semantics
|
// Use `using (var scope=db.Transaction) { scope.Complete(); }` to ensure correct semantics
|
||||||
public void BeginTransaction(IsolationLevel? isolationLevel)
|
public void BeginTransaction(IsolationLevel? isolationLevel)
|
||||||
{
|
|
||||||
_transactionDepth++;
|
|
||||||
|
|
||||||
if (_transactionDepth == 1)
|
|
||||||
{
|
{
|
||||||
OpenSharedConnection();
|
OpenSharedConnection();
|
||||||
_transaction = isolationLevel == null ? _sharedConnection.BeginTransaction() : _sharedConnection.BeginTransaction(isolationLevel.Value);
|
_transaction = isolationLevel == null ? _sharedConnection.BeginTransaction() : _sharedConnection.BeginTransaction(isolationLevel.Value);
|
||||||
_transactionCancelled = false;
|
_transactionCancelled = false;
|
||||||
OnBeginTransaction();
|
OnBeginTransaction();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,14 +469,12 @@ void CleanupTransaction()
|
||||||
public void AbortTransaction()
|
public void AbortTransaction()
|
||||||
{
|
{
|
||||||
_transactionCancelled = true;
|
_transactionCancelled = true;
|
||||||
if ((--_transactionDepth) == 0)
|
|
||||||
CleanupTransaction();
|
CleanupTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Complete the transaction
|
// Complete the transaction
|
||||||
public void CompleteTransaction()
|
public void CompleteTransaction()
|
||||||
{
|
{
|
||||||
if ((--_transactionDepth) == 0)
|
|
||||||
CleanupTransaction();
|
CleanupTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2524,7 +2518,6 @@ static T RecurseInheritedTypes<T>(Type t, Func<Type, T> cb)
|
||||||
DbProviderFactory _factory;
|
DbProviderFactory _factory;
|
||||||
IDbConnection _sharedConnection;
|
IDbConnection _sharedConnection;
|
||||||
IDbTransaction _transaction;
|
IDbTransaction _transaction;
|
||||||
int _transactionDepth;
|
|
||||||
bool _transactionCancelled;
|
bool _transactionCancelled;
|
||||||
string _lastSql;
|
string _lastSql;
|
||||||
object[] _lastArgs;
|
object[] _lastArgs;
|
||||||
|
|
Loading…
Reference in a new issue