diff --git a/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs b/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs index 02dff0ba2..3fba6211a 100644 --- a/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs +++ b/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs @@ -7,6 +7,7 @@ using System.Text; using NHibernate; using NHibernate.Dialect; using NHibernate.SqlTypes; +using Orchard.ContentManagement.Records; using Orchard.Data.Migration.Schema; using Orchard.Environment.Configuration; using Orchard.Localization; @@ -16,8 +17,8 @@ using Orchard.Reports.Services; namespace Orchard.Data.Migration.Interpreters { public class DefaultDataMigrationInterpreter : AbstractDataMigrationInterpreter, IDataMigrationInterpreter { private readonly ShellSettings _shellSettings; + private readonly ISessionLocator _sessionLocator; private readonly IEnumerable _commandInterpreters; - private readonly ISession _session; private readonly Dialect _dialect; private readonly List _sqlStatements; private readonly ISessionFactoryHolder _sessionFactoryHolder; @@ -32,8 +33,8 @@ namespace Orchard.Data.Migration.Interpreters { ISessionFactoryHolder sessionFactoryHolder, IReportsCoordinator reportsCoordinator) { _shellSettings = shellSettings; + _sessionLocator = sessionLocator; _commandInterpreters = commandInterpreters; - _session = sessionLocator.For(typeof(DefaultDataMigrationInterpreter)); _sqlStatements = new List(); _sessionFactoryHolder = sessionFactoryHolder; _reportsCoordinator = reportsCoordinator; @@ -335,7 +336,8 @@ namespace Orchard.Data.Migration.Interpreters { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities", Justification = "Nothing comes from user input.")] private void RunPendingStatements() { - var connection = _session.Connection; + var session = _sessionLocator.For(typeof(ContentItemRecord)); + var connection = session.Connection; foreach (var sqlStatement in _sqlStatements) { Logger.Debug(sqlStatement); diff --git a/src/Orchard/Data/SessionLocator.cs b/src/Orchard/Data/SessionLocator.cs index c1fcd725b..6c3f73d89 100644 --- a/src/Orchard/Data/SessionLocator.cs +++ b/src/Orchard/Data/SessionLocator.cs @@ -31,19 +31,14 @@ namespace Orchard.Data { _transactionManager.Demand(); Logger.Information("Openning database session"); - _session = sessionFactory.OpenSession(new SessionInterceptor(this)); + _session = sessionFactory.OpenSession(new SessionInterceptor()); } return _session; } class SessionInterceptor : IInterceptor { - private readonly SessionLocator _sessionLocator; private ISession _session; - public SessionInterceptor(SessionLocator sessionLocator) { - _sessionLocator = sessionLocator; - } - bool IInterceptor.OnLoad(object entity, object id, object[] state, string[] propertyNames, IType[] types) { return false; }