Persistence reorg, killed DatabaseContext
This commit is contained in:
@@ -9,7 +9,9 @@ namespace Umbraco.Core
|
||||
public class ApplicationContext : IDisposable
|
||||
{
|
||||
private ApplicationContext()
|
||||
{ }
|
||||
{
|
||||
DatabaseContext = new DatabaseContext(DI.Current.DatabaseFactory);
|
||||
}
|
||||
|
||||
public static ApplicationContext Current { get; } = new ApplicationContext();
|
||||
|
||||
@@ -23,7 +25,7 @@ namespace Umbraco.Core
|
||||
|
||||
public bool IsUpgrading => DI.Current.RuntimeState.Level == RuntimeLevel.Upgrade;
|
||||
|
||||
public DatabaseContext DatabaseContext => DI.Current.DatabaseContext;
|
||||
public DatabaseContext DatabaseContext { get; }
|
||||
|
||||
public ServiceContext Services => DI.Current.Services;
|
||||
|
||||
|
||||
@@ -1,96 +1,76 @@
|
||||
using System;
|
||||
using NPoco;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Umbraco database context.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>The database context creates Sql statements and IQuery expressions.</para>
|
||||
/// <para>The database context provides the SqlSyntax and the DatabaseType.</para>
|
||||
/// <para>The database context provides access to the "ambient" database.</para>
|
||||
/// <para>The database context provides basic status infos (whether the db is configured and can connect).</para>
|
||||
/// </remarks>
|
||||
public class DatabaseContext
|
||||
{
|
||||
private readonly IUmbracoDatabaseFactory _databaseFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DatabaseContext"/> class.
|
||||
/// </summary>
|
||||
/// <param name="databaseFactory">A database factory.</param>
|
||||
/// <remarks>The database factory will try to configure itself but may fail eg if the default
|
||||
/// Umbraco connection string is not available because we are installing. In which case this
|
||||
/// database builder must sort things out and configure the database factory before it can be
|
||||
/// used.</remarks>
|
||||
public DatabaseContext(IUmbracoDatabaseFactory databaseFactory)
|
||||
{
|
||||
if (databaseFactory == null) throw new ArgumentNullException(nameof(databaseFactory));
|
||||
|
||||
_databaseFactory = databaseFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the database Sql syntax.
|
||||
/// </summary>
|
||||
public ISqlSyntaxProvider SqlSyntax => _databaseFactory.SqlSyntax;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Sql statement.
|
||||
/// </summary>
|
||||
public Sql<SqlContext> Sql() => _databaseFactory.Sql();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Sql statement.
|
||||
/// </summary>
|
||||
public Sql<SqlContext> Sql(string sql, params object[] args) => _databaseFactory.Sql(sql, args);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Query expression.
|
||||
/// </summary>
|
||||
public IQuery<T> Query<T>() => _databaseFactory.Query<T>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets an ambient database for doing CRUD operations against custom tables that resides in the Umbraco database.
|
||||
/// </summary>
|
||||
/// <remarks>Should not be used for operation against standard Umbraco tables; as services should be used instead.</remarks>
|
||||
public IUmbracoDatabase Database => _databaseFactory.GetDatabase();
|
||||
|
||||
/// <summary>
|
||||
/// Gets an ambient database scope.
|
||||
/// </summary>
|
||||
/// <returns>A disposable object representing the scope.</returns>
|
||||
public IDisposable CreateDatabaseScope() // fixme - move over to factory
|
||||
{
|
||||
return _databaseFactory.CreateScope();
|
||||
}
|
||||
|
||||
#if DEBUG_DATABASES
|
||||
public List<UmbracoDatabase> Databases
|
||||
{
|
||||
get
|
||||
{
|
||||
var factory = _databaseFactory as UmbracoDatabaseFactory;
|
||||
if (factory == null) throw new NotSupportedException();
|
||||
return factory.Databases;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the database is configured.
|
||||
/// </summary>
|
||||
/// <remarks>It does not necessarily mean that it is possible to
|
||||
/// connect, nor that Umbraco is installed, nor up-to-date.</remarks>
|
||||
public bool IsDatabaseConfigured => _databaseFactory.Configured;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether it is possible to connect to the database.
|
||||
/// </summary>
|
||||
public bool CanConnect => _databaseFactory.Configured && _databaseFactory.CanConnect;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using NPoco;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
public class DatabaseContext
|
||||
{
|
||||
private readonly IUmbracoDatabaseFactory _databaseFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Umbraco.Core.DatabaseContext"/> class.
|
||||
/// </summary>
|
||||
/// <param name="databaseFactory">A database factory.</param>
|
||||
/// <remarks>The database factory will try to configure itself but may fail eg if the default
|
||||
/// Umbraco connection string is not available because we are installing. In which case this
|
||||
/// database builder must sort things out and configure the database factory before it can be
|
||||
/// used.</remarks>
|
||||
public DatabaseContext(IUmbracoDatabaseFactory databaseFactory)
|
||||
{
|
||||
if (databaseFactory == null) throw new ArgumentNullException(nameof(databaseFactory));
|
||||
|
||||
_databaseFactory = databaseFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the database Sql syntax.
|
||||
/// </summary>
|
||||
public ISqlSyntaxProvider SqlSyntax => _databaseFactory.SqlSyntax;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Sql statement.
|
||||
/// </summary>
|
||||
public Sql<SqlContext> Sql() => _databaseFactory.Sql();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Sql statement.
|
||||
/// </summary>
|
||||
public Sql<SqlContext> Sql(string sql, params object[] args) => _databaseFactory.Sql(sql, args);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Query expression.
|
||||
/// </summary>
|
||||
public IQuery<T> Query<T>() => _databaseFactory.Query<T>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets an ambient database for doing CRUD operations against custom tables that resides in the Umbraco database.
|
||||
/// </summary>
|
||||
/// <remarks>Should not be used for operation against standard Umbraco tables; as services should be used instead.</remarks>
|
||||
public IUmbracoDatabase Database => _databaseFactory.GetDatabase();
|
||||
|
||||
/// <summary>
|
||||
/// Gets an ambient database scope.
|
||||
/// </summary>
|
||||
/// <returns>A disposable object representing the scope.</returns>
|
||||
public IDisposable CreateDatabaseScope() // fixme - move over to factory
|
||||
{
|
||||
return _databaseFactory.CreateScope();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the database is configured.
|
||||
/// </summary>
|
||||
/// <remarks>It does not necessarily mean that it is possible to
|
||||
/// connect, nor that Umbraco is installed, nor up-to-date.</remarks>
|
||||
public bool IsDatabaseConfigured => _databaseFactory.Configured;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether it is possible to connect to the database.
|
||||
/// </summary>
|
||||
public bool CanConnect => _databaseFactory.Configured && _databaseFactory.CanConnect;
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@
|
||||
<Compile Include="Core\ApplicationContext.cs" />
|
||||
<Compile Include="Core\ApplicationEventHandler.cs" />
|
||||
<Compile Include="Core\Cache\CacheRefreshersResolver.cs" />
|
||||
<Compile Include="Core\DatabaseContext.cs" />
|
||||
<Compile Include="Core\Dictionary\CultureDictionaryFactoryResolver.cs" />
|
||||
<Compile Include="Core\IApplicationEventHandler.cs" />
|
||||
<Compile Include="Core\Logging\LoggerResolver.cs" />
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using LightInject;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
|
||||
namespace Umbraco.Core.Components
|
||||
{
|
||||
@@ -48,7 +49,7 @@ namespace Umbraco.Core.Components
|
||||
InstanciateComponents(orderedComponentTypes);
|
||||
ComposeComponents(level);
|
||||
|
||||
using (_container.GetInstance<DatabaseContext>().CreateDatabaseScope())
|
||||
using (_container.GetInstance<IUmbracoDatabaseFactory>().CreateScope())
|
||||
{
|
||||
InitializeComponents();
|
||||
}
|
||||
|
||||
@@ -227,9 +227,6 @@ namespace Umbraco.Core
|
||||
// until the database context configures it properly (eg when installing)
|
||||
container.RegisterSingleton<IUmbracoDatabaseFactory, UmbracoDatabaseFactory>();
|
||||
|
||||
// register database context
|
||||
container.RegisterSingleton<DatabaseContext>();
|
||||
|
||||
// register a database accessor - required by database factory
|
||||
// will be replaced by HybridUmbracoDatabaseAccessor in the web runtime
|
||||
// fixme - we should NOT be using thread static at all + will NOT get replaced = wtf?
|
||||
|
||||
@@ -14,6 +14,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Manifest;
|
||||
using Umbraco.Core.Models.Mapping;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Migrations;
|
||||
using Umbraco.Core.Plugins;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
@@ -93,7 +94,7 @@ namespace Umbraco.Core
|
||||
composition.Container.RegisterSingleton<IServerMessenger>(factory
|
||||
=> new DatabaseServerMessenger(
|
||||
factory.GetInstance<IRuntimeState>(),
|
||||
factory.GetInstance<DatabaseContext>(),
|
||||
factory.GetInstance<IUmbracoDatabaseFactory>(),
|
||||
factory.GetInstance<ILogger>(),
|
||||
factory.GetInstance<ProfilingLogger>(),
|
||||
true, new DatabaseServerMessengerOptions()));
|
||||
|
||||
@@ -6,6 +6,7 @@ using Umbraco.Core.Dictionary;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Plugins;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -70,8 +71,8 @@ namespace Umbraco.Core.DI
|
||||
|
||||
public static PluginManager PluginManager
|
||||
{
|
||||
get { return _pluginManager
|
||||
?? (_pluginManager = Container.TryGetInstance<PluginManager>()
|
||||
get { return _pluginManager
|
||||
?? (_pluginManager = Container.TryGetInstance<PluginManager>()
|
||||
?? new PluginManager(ApplicationCache.RuntimeCache, ProfilingLogger)); }
|
||||
set { _pluginManager = value; }
|
||||
}
|
||||
@@ -146,8 +147,8 @@ namespace Umbraco.Core.DI
|
||||
public static ServiceContext Services
|
||||
=> Container.GetInstance<ServiceContext>();
|
||||
|
||||
public static DatabaseContext DatabaseContext
|
||||
=> Container.GetInstance<DatabaseContext>();
|
||||
public static IUmbracoDatabaseFactory DatabaseFactory
|
||||
=> Container.GetInstance<IUmbracoDatabaseFactory>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -16,9 +16,6 @@ namespace Umbraco.Core.DI
|
||||
|
||||
public void Compose(IServiceRegistry container)
|
||||
{
|
||||
// register database context
|
||||
container.RegisterSingleton<DatabaseContext>();
|
||||
|
||||
// register IUnitOfWork providers
|
||||
container.RegisterSingleton<IUnitOfWorkProvider, FileUnitOfWorkProvider>();
|
||||
container.RegisterSingleton<IDatabaseUnitOfWorkProvider, NPocoUnitOfWorkProvider>();
|
||||
|
||||
@@ -293,7 +293,7 @@ namespace Umbraco.Core
|
||||
}
|
||||
|
||||
xml.Save(fileName, SaveOptions.DisableFormatting);
|
||||
logger.Info<DatabaseContext>("Configured a new ConnectionString using the '" + providerName + "' provider.");
|
||||
logger.Info<DatabaseBuilder>("Configured a new ConnectionString using the '" + providerName + "' provider.");
|
||||
}
|
||||
|
||||
internal bool IsConnectionStringConfigured(ConnectionStringSettings databaseSettings)
|
||||
@@ -399,7 +399,7 @@ namespace Umbraco.Core
|
||||
return readyForInstall.Result;
|
||||
}
|
||||
|
||||
_logger.Info<DatabaseContext>("Database configuration status: Started");
|
||||
_logger.Info<DatabaseBuilder>("Database configuration status: Started");
|
||||
|
||||
var database = _databaseFactory.GetDatabase();
|
||||
|
||||
@@ -434,12 +434,12 @@ namespace Umbraco.Core
|
||||
message = message + "<p>Installation completed!</p>";
|
||||
|
||||
//now that everything is done, we need to determine the version of SQL server that is executing
|
||||
_logger.Info<DatabaseContext>("Database configuration status: " + message);
|
||||
_logger.Info<DatabaseBuilder>("Database configuration status: " + message);
|
||||
return new Result { Message = message, Success = true, Percentage = "100" };
|
||||
}
|
||||
|
||||
//we need to do an upgrade so return a new status message and it will need to be done during the next step
|
||||
_logger.Info<DatabaseContext>("Database requires upgrade");
|
||||
_logger.Info<DatabaseBuilder>("Database requires upgrade");
|
||||
message = "<p>Upgrading database, this may take some time...</p>";
|
||||
return new Result
|
||||
{
|
||||
@@ -469,7 +469,7 @@ namespace Umbraco.Core
|
||||
return readyForInstall.Result;
|
||||
}
|
||||
|
||||
_logger.Info<DatabaseContext>("Database upgrade started");
|
||||
_logger.Info<DatabaseBuilder>("Database upgrade started");
|
||||
|
||||
var database = _databaseFactory.GetDatabase();
|
||||
//var supportsCaseInsensitiveQueries = SqlSyntax.SupportsCaseInsensitiveQueries(database);
|
||||
@@ -525,7 +525,7 @@ namespace Umbraco.Core
|
||||
|
||||
//now that everything is done, we need to determine the version of SQL server that is executing
|
||||
|
||||
_logger.Info<DatabaseContext>("Database configuration status: " + message);
|
||||
_logger.Info<DatabaseBuilder>("Database configuration status: " + message);
|
||||
|
||||
return new Result { Message = message, Success = true, Percentage = "100" };
|
||||
}
|
||||
@@ -594,11 +594,11 @@ namespace Umbraco.Core
|
||||
|
||||
private Result HandleInstallException(Exception ex)
|
||||
{
|
||||
_logger.Error<DatabaseContext>("Database configuration failed", ex);
|
||||
_logger.Error<DatabaseBuilder>("Database configuration failed", ex);
|
||||
|
||||
if (_databaseSchemaValidationResult != null)
|
||||
{
|
||||
_logger.Info<DatabaseContext>("The database schema validation produced the following summary: \n" + _databaseSchemaValidationResult.GetSummary());
|
||||
_logger.Info<DatabaseBuilder>("The database schema validation produced the following summary: \n" + _databaseSchemaValidationResult.GetSummary());
|
||||
}
|
||||
|
||||
return new Result
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
|
||||
//TODO: We need to refactor this so the packager isn't making direct db calls for an 'edge' case
|
||||
var database = Current.DatabaseContext.Database;
|
||||
var database = Current.DatabaseFactory.Database;
|
||||
var dtos = database.Fetch<DataTypePreValueDto>("WHERE datatypeNodeId = @Id", new { Id = propertyType.DataTypeDefinitionId });
|
||||
|
||||
var propertyValueList = new List<string>();
|
||||
|
||||
@@ -42,16 +42,16 @@ namespace Umbraco.Core.Sync
|
||||
protected DatabaseServerMessengerOptions Options { get; }
|
||||
|
||||
public DatabaseServerMessenger(
|
||||
IRuntimeState runtime, DatabaseContext dbContext, ILogger logger, ProfilingLogger proflog,
|
||||
IRuntimeState runtime, IUmbracoDatabaseFactory databaseFactory, ILogger logger, ProfilingLogger proflog,
|
||||
bool distributedEnabled, DatabaseServerMessengerOptions options)
|
||||
: base(distributedEnabled)
|
||||
{
|
||||
if (dbContext == null) throw new ArgumentNullException(nameof(dbContext));
|
||||
if (databaseFactory == null) throw new ArgumentNullException(nameof(databaseFactory));
|
||||
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
||||
if (proflog == null) throw new ArgumentNullException(nameof(proflog));
|
||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||
|
||||
DatabaseContext = dbContext;
|
||||
DatabaseFactory = databaseFactory;
|
||||
Logger = logger;
|
||||
_runtime = runtime;
|
||||
_profilingLogger = proflog;
|
||||
@@ -62,11 +62,11 @@ namespace Umbraco.Core.Sync
|
||||
|
||||
protected ILogger Logger { get; }
|
||||
|
||||
protected DatabaseContext DatabaseContext { get; }
|
||||
protected IUmbracoDatabaseFactory DatabaseFactory { get; }
|
||||
|
||||
protected IUmbracoDatabase Database => DatabaseContext.Database;
|
||||
protected IUmbracoDatabase Database => DatabaseFactory.Database;
|
||||
|
||||
protected Sql<SqlContext> Sql() => DatabaseContext.Sql();
|
||||
protected Sql<SqlContext> Sql() => DatabaseFactory.Sql();
|
||||
|
||||
#region Messenger
|
||||
|
||||
|
||||
@@ -226,7 +226,6 @@
|
||||
<Compile Include="CoreRuntimeComponent.cs" />
|
||||
<Compile Include="DatabaseBuilder.cs" />
|
||||
<Compile Include="DI\Current.cs" />
|
||||
<Compile Include="DatabaseContext.cs" />
|
||||
<Compile Include="DataTableExtensions.cs" />
|
||||
<Compile Include="DateTimeExtensions.cs" />
|
||||
<Compile Include="DecimalExtensions.cs" />
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Umbraco.Tests.Components
|
||||
var mock = new Mock<IServiceContainer>();
|
||||
mock.Setup(x => x.GetInstance<ILogger>()).Returns(logger);
|
||||
mock.Setup(x => x.GetInstance<ProfilingLogger>()).Returns(new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
mock.Setup(x => x.GetInstance<DatabaseContext>()).Returns(new DatabaseContext(f));
|
||||
mock.Setup(x => x.GetInstance<IUmbracoDatabaseFactory>()).Returns(f);
|
||||
setup?.Invoke(mock);
|
||||
return mock.Object;
|
||||
}
|
||||
|
||||
@@ -35,14 +35,14 @@ namespace Umbraco.Tests.Migrations
|
||||
ParentId = -1,
|
||||
UniqueId = Guid.NewGuid()
|
||||
};
|
||||
DatabaseContext.Database.Insert(n);
|
||||
DatabaseFactory.Database.Insert(n);
|
||||
var ct = new ContentTypeDto
|
||||
{
|
||||
Alias = "alias",
|
||||
NodeId = n.NodeId,
|
||||
Thumbnail = "thumb"
|
||||
};
|
||||
DatabaseContext.Database.Insert(ct);
|
||||
DatabaseFactory.Database.Insert(ct);
|
||||
n = new NodeDto
|
||||
{
|
||||
Text = "text",
|
||||
@@ -51,21 +51,21 @@ namespace Umbraco.Tests.Migrations
|
||||
ParentId = -1,
|
||||
UniqueId = Guid.NewGuid()
|
||||
};
|
||||
DatabaseContext.Database.Insert(n);
|
||||
DatabaseFactory.Database.Insert(n);
|
||||
var dt = new DataTypeDto
|
||||
{
|
||||
PropertyEditorAlias = Constants.PropertyEditors.RelatedLinksAlias,
|
||||
DbType = "x",
|
||||
DataTypeId = n.NodeId
|
||||
};
|
||||
DatabaseContext.Database.Insert(dt);
|
||||
DatabaseFactory.Database.Insert(dt);
|
||||
var pt = new PropertyTypeDto
|
||||
{
|
||||
Alias = "alias",
|
||||
ContentTypeId = ct.NodeId,
|
||||
DataTypeId = dt.DataTypeId
|
||||
};
|
||||
DatabaseContext.Database.Insert(pt);
|
||||
DatabaseFactory.Database.Insert(pt);
|
||||
n = new NodeDto
|
||||
{
|
||||
Text = "text",
|
||||
@@ -74,7 +74,7 @@ namespace Umbraco.Tests.Migrations
|
||||
ParentId = -1,
|
||||
UniqueId = Guid.NewGuid()
|
||||
};
|
||||
DatabaseContext.Database.Insert(n);
|
||||
DatabaseFactory.Database.Insert(n);
|
||||
var data = new PropertyDataDto
|
||||
{
|
||||
NodeId = n.NodeId,
|
||||
@@ -82,7 +82,7 @@ namespace Umbraco.Tests.Migrations
|
||||
Text = "text",
|
||||
VersionId = Guid.NewGuid()
|
||||
};
|
||||
DatabaseContext.Database.Insert(data);
|
||||
DatabaseFactory.Database.Insert(data);
|
||||
data = new PropertyDataDto
|
||||
{
|
||||
NodeId = n.NodeId,
|
||||
@@ -90,13 +90,13 @@ namespace Umbraco.Tests.Migrations
|
||||
Text = "<root><node title=\"\" type=\"\" newwindow=\"\" link=\"\" /></root>",
|
||||
VersionId = Guid.NewGuid()
|
||||
};
|
||||
DatabaseContext.Database.Insert(data);
|
||||
var migrationContext = new MigrationContext(DatabaseContext.Database, Logger);
|
||||
DatabaseFactory.Database.Insert(data);
|
||||
var migrationContext = new MigrationContext(DatabaseFactory.Database, Logger);
|
||||
|
||||
var migration = new UpdateRelatedLinksData(migrationContext);
|
||||
migration.UpdateRelatedLinksDataDo(DatabaseContext.Database);
|
||||
migration.UpdateRelatedLinksDataDo(DatabaseFactory.Database);
|
||||
|
||||
data = DatabaseContext.Database.Fetch<PropertyDataDto>("SELECT * FROM cmsPropertyData WHERE id=" + data.Id).FirstOrDefault();
|
||||
data = DatabaseFactory.Database.Fetch<PropertyDataDto>("SELECT * FROM cmsPropertyData WHERE id=" + data.Id).FirstOrDefault();
|
||||
Assert.IsNotNull(data);
|
||||
Debug.Print(data.Text);
|
||||
Assert.AreEqual("[{\"title\":\"\",\"caption\":\"\",\"link\":\"\",\"newWindow\":false,\"type\":\"external\",\"internal\":null,\"edit\":false,\"isInternal\":false}]",
|
||||
@@ -108,7 +108,7 @@ namespace Umbraco.Tests.Migrations
|
||||
{
|
||||
var logger = new DebugDiagnosticsLogger();
|
||||
|
||||
var migrationContext = new MigrationContext(DatabaseContext.Database, Logger);
|
||||
var migrationContext = new MigrationContext(DatabaseFactory.Database, Logger);
|
||||
|
||||
//Setup the MigrationRunner
|
||||
var migrationRunner = new MigrationRunner(
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Tests.Persistence
|
||||
[TestFixture, RequiresSTA]
|
||||
public class DatabaseContextTests
|
||||
{
|
||||
private DatabaseContext _dbContext;
|
||||
private IUmbracoDatabaseFactory _databaseFactory;
|
||||
private ILogger _logger;
|
||||
private SqlCeSyntaxProvider _sqlCeSyntaxProvider;
|
||||
private ISqlSyntaxProvider[] _sqlSyntaxProviders;
|
||||
@@ -38,16 +38,15 @@ namespace Umbraco.Tests.Persistence
|
||||
_sqlCeSyntaxProvider = new SqlCeSyntaxProvider();
|
||||
_sqlSyntaxProviders = new[] { (ISqlSyntaxProvider) _sqlCeSyntaxProvider };
|
||||
_logger = Mock.Of<ILogger>();
|
||||
var dbFactory = new UmbracoDatabaseFactory(Core.Configuration.GlobalSettings.UmbracoConnectionName, _sqlSyntaxProviders, _logger, new TestDatabaseScopeAccessor(), Mock.Of<IMapperCollection>());
|
||||
_databaseFactory = new UmbracoDatabaseFactory(Core.Configuration.GlobalSettings.UmbracoConnectionName, _sqlSyntaxProviders, _logger, new TestDatabaseScopeAccessor(), Mock.Of<IMapperCollection>());
|
||||
_runtime = Mock.Of<IRuntimeState>();
|
||||
_migrationEntryService = Mock.Of<IMigrationEntryService>();
|
||||
_dbContext = new DatabaseContext(dbFactory);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
_dbContext = null;
|
||||
_databaseFactory = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -55,7 +54,7 @@ namespace Umbraco.Tests.Persistence
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() =>
|
||||
{
|
||||
var db = _dbContext.Database;
|
||||
var db = _databaseFactory.Database;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,10 +63,10 @@ namespace Umbraco.Tests.Persistence
|
||||
{
|
||||
IUmbracoDatabase db1, db2;
|
||||
|
||||
using (_dbContext.CreateDatabaseScope())
|
||||
using (_databaseFactory.CreateScope())
|
||||
{
|
||||
db1 = _dbContext.Database;
|
||||
db2 = _dbContext.Database;
|
||||
db1 = _databaseFactory.Database;
|
||||
db2 = _databaseFactory.Database;
|
||||
}
|
||||
|
||||
Assert.AreSame(db1, db2);
|
||||
@@ -78,13 +77,13 @@ namespace Umbraco.Tests.Persistence
|
||||
{
|
||||
IUmbracoDatabase db1, db2;
|
||||
|
||||
using (_dbContext.CreateDatabaseScope())
|
||||
using (_databaseFactory.CreateScope())
|
||||
{
|
||||
db1 = _dbContext.Database;
|
||||
db1 = _databaseFactory.Database;
|
||||
}
|
||||
using (_dbContext.CreateDatabaseScope())
|
||||
using (_databaseFactory.CreateScope())
|
||||
{
|
||||
db2 = _dbContext.Database;
|
||||
db2 = _databaseFactory.Database;
|
||||
}
|
||||
|
||||
Assert.AreNotSame(db1, db2);
|
||||
@@ -93,9 +92,9 @@ namespace Umbraco.Tests.Persistence
|
||||
[Test]
|
||||
public void GetDatabaseType()
|
||||
{
|
||||
using (_dbContext.CreateDatabaseScope())
|
||||
using (_databaseFactory.CreateScope())
|
||||
{
|
||||
var databaseType = _dbContext.Database.DatabaseType;
|
||||
var databaseType = _databaseFactory.Database.DatabaseType;
|
||||
Assert.AreEqual(DatabaseType.SQLCe, databaseType);
|
||||
}
|
||||
}
|
||||
@@ -124,21 +123,20 @@ namespace Umbraco.Tests.Persistence
|
||||
}
|
||||
|
||||
// re-create the database factory and database context with proper connection string
|
||||
var dbFactory = new UmbracoDatabaseFactory(connString, Constants.DbProviderNames.SqlCe, _sqlSyntaxProviders, _logger, new TestDatabaseScopeAccessor(), Mock.Of<IMapperCollection>());
|
||||
_dbContext = new DatabaseContext(dbFactory);
|
||||
_databaseFactory = new UmbracoDatabaseFactory(connString, Constants.DbProviderNames.SqlCe, _sqlSyntaxProviders, _logger, new TestDatabaseScopeAccessor(), Mock.Of<IMapperCollection>());
|
||||
|
||||
// create application context
|
||||
//var appCtx = new ApplicationContext(
|
||||
// _dbContext,
|
||||
// _databaseFactory,
|
||||
// new ServiceContext(migrationEntryService: Mock.Of<IMigrationEntryService>()),
|
||||
// CacheHelper.CreateDisabledCacheHelper(),
|
||||
// new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
|
||||
// create the umbraco database
|
||||
DatabaseSchemaHelper schemaHelper;
|
||||
using (_dbContext.CreateDatabaseScope())
|
||||
using (_databaseFactory.CreateScope())
|
||||
{
|
||||
schemaHelper = new DatabaseSchemaHelper(_dbContext.Database, _logger);
|
||||
schemaHelper = new DatabaseSchemaHelper(_databaseFactory.Database, _logger);
|
||||
schemaHelper.CreateDatabaseSchema(_runtime, _migrationEntryService, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Umbraco.Tests.Persistence
|
||||
base.Initialize();
|
||||
|
||||
// create a few lock objects
|
||||
var database = DatabaseContext.Database;
|
||||
var database = DatabaseFactory.Database;
|
||||
database.BeginTransaction(IsolationLevel.RepeatableRead);
|
||||
try
|
||||
{
|
||||
@@ -63,7 +63,7 @@ namespace Umbraco.Tests.Persistence
|
||||
[Test]
|
||||
public void SingleReadLockTest()
|
||||
{
|
||||
var database = DatabaseContext.Database;
|
||||
var database = DatabaseFactory.Database;
|
||||
database.BeginTransaction(IsolationLevel.RepeatableRead);
|
||||
try
|
||||
{
|
||||
@@ -107,12 +107,12 @@ namespace Umbraco.Tests.Persistence
|
||||
private void ConcurrentReadersTestThread(Exception[] exceptions, int index, object locker, ref int acquired, int threadCount, ManualResetEventSlim ev)
|
||||
{
|
||||
// in a thread, must create a scope
|
||||
using (DatabaseContext.CreateDatabaseScope())
|
||||
using (DatabaseFactory.CreateScope())
|
||||
{
|
||||
IUmbracoDatabase database;
|
||||
try
|
||||
{
|
||||
database = DatabaseContext.Database;
|
||||
database = DatabaseFactory.Database;
|
||||
database.BeginTransaction(IsolationLevel.RepeatableRead);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -173,12 +173,12 @@ namespace Umbraco.Tests.Persistence
|
||||
private void ConcurrentWritersTestThread(Exception[] exceptions, int index, object locker, ref int acquired)
|
||||
{
|
||||
// in a thread, must create a scope
|
||||
using (DatabaseContext.CreateDatabaseScope())
|
||||
using (DatabaseFactory.CreateScope())
|
||||
{
|
||||
IUmbracoDatabase database;
|
||||
try
|
||||
{
|
||||
database = DatabaseContext.Database;
|
||||
database = DatabaseFactory.Database;
|
||||
database.BeginTransaction(IsolationLevel.RepeatableRead);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -240,12 +240,12 @@ namespace Umbraco.Tests.Persistence
|
||||
private void DeadLockTestThread(int id1, int id2, EventWaitHandle myEv, WaitHandle otherEv, ref Exception exception)
|
||||
{
|
||||
// in a thread, must create a scope
|
||||
using (DatabaseContext.CreateDatabaseScope())
|
||||
using (DatabaseFactory.CreateScope())
|
||||
{
|
||||
IUmbracoDatabase database;
|
||||
try
|
||||
{
|
||||
database = DatabaseContext.Database;
|
||||
database = DatabaseFactory.Database;
|
||||
database.BeginTransaction(IsolationLevel.RepeatableRead);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -315,7 +315,7 @@ namespace Umbraco.Tests.Persistence
|
||||
|
||||
private void NoDeadLockTestThread(int id, EventWaitHandle myEv, WaitHandle otherEv, ref Exception exception)
|
||||
{
|
||||
var database = DatabaseContext.Database;
|
||||
var database = DatabaseFactory.Database;
|
||||
try
|
||||
{
|
||||
database.BeginTransaction(IsolationLevel.RepeatableRead);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Bulk_Insert_One_By_One()
|
||||
{
|
||||
// Arrange
|
||||
var db = DatabaseContext.Database;
|
||||
var db = DatabaseFactory.Database;
|
||||
|
||||
var servers = new List<ServerRegistrationDto>();
|
||||
for (var i = 0; i < 1000; i++)
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Bulk_Insert_One_By_One_Transaction_Rollback()
|
||||
{
|
||||
// Arrange
|
||||
var db = DatabaseContext.Database;
|
||||
var db = DatabaseFactory.Database;
|
||||
|
||||
var servers = new List<ServerRegistrationDto>();
|
||||
for (var i = 0; i < 1000; i++)
|
||||
@@ -139,7 +139,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Bulk_Insert_Native_Sql_Bulk_Inserts()
|
||||
{
|
||||
// Arrange
|
||||
var db = DatabaseContext.Database;
|
||||
var db = DatabaseFactory.Database;
|
||||
|
||||
var servers = new List<ServerRegistrationDto>();
|
||||
for (var i = 0; i < 1000; i++)
|
||||
@@ -172,7 +172,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Bulk_Insert_Native_Sql_Bulk_Inserts_Transaction_Rollback()
|
||||
{
|
||||
// Arrange
|
||||
var db = DatabaseContext.Database;
|
||||
var db = DatabaseFactory.Database;
|
||||
|
||||
var servers = new List<ServerRegistrationDto>();
|
||||
for (var i = 0; i < 1000; i++)
|
||||
@@ -205,7 +205,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Generate_Bulk_Import_Sql()
|
||||
{
|
||||
// Arrange
|
||||
var db = DatabaseContext.Database;
|
||||
var db = DatabaseFactory.Database;
|
||||
|
||||
var servers = new List<ServerRegistrationDto>();
|
||||
for (var i = 0; i < 2; i++)
|
||||
@@ -235,7 +235,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Generate_Bulk_Import_Sql_Exceeding_Max_Params()
|
||||
{
|
||||
// Arrange
|
||||
var db = DatabaseContext.Database;
|
||||
var db = DatabaseFactory.Database;
|
||||
|
||||
var servers = new List<ServerRegistrationDto>();
|
||||
for (var i = 0; i < 1500; i++)
|
||||
|
||||
@@ -23,35 +23,35 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
[Test]
|
||||
public void Can_Map_Content_Type_Templates_And_Allowed_Types()
|
||||
{
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
DatabaseContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 55554, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,55554", SortOrder = 1, UniqueId = new Guid("87D1EAB6-AB27-4852-B3DF-DE8DBA4A1AA0"), Text = "Template 1", NodeObjectType = new Guid(Constants.ObjectTypes.Template), CreateDate = DateTime.Now });
|
||||
DatabaseContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 55555, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,55555", SortOrder = 1, UniqueId = new Guid("3390BDF4-C974-4211-AA95-3812A8CE7C46"), Text = "Template 2", NodeObjectType = new Guid(Constants.ObjectTypes.Template), CreateDate = DateTime.Now });
|
||||
DatabaseContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99997, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99997", SortOrder = 0, UniqueId = new Guid("BB3241D5-6842-4EFA-A82A-5F56885CF528"), Text = "Test Content Type 1", NodeObjectType = new Guid(Constants.ObjectTypes.DocumentType), CreateDate = DateTime.Now });
|
||||
DatabaseContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99998, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99998", SortOrder = 0, UniqueId = new Guid("EEA66B06-302E-49BA-A8B2-EDF07248BC59"), Text = "Test Content Type 2", NodeObjectType = new Guid(Constants.ObjectTypes.DocumentType), CreateDate = DateTime.Now });
|
||||
DatabaseContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99999, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99999", SortOrder = 0, UniqueId = new Guid("C45CC083-BB27-4C1C-B448-6F703CC9B799"), Text = "Test Content Type 2", NodeObjectType = new Guid(Constants.ObjectTypes.DocumentType), CreateDate = DateTime.Now });
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
DatabaseFactory.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 55554, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,55554", SortOrder = 1, UniqueId = new Guid("87D1EAB6-AB27-4852-B3DF-DE8DBA4A1AA0"), Text = "Template 1", NodeObjectType = new Guid(Constants.ObjectTypes.Template), CreateDate = DateTime.Now });
|
||||
DatabaseFactory.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 55555, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,55555", SortOrder = 1, UniqueId = new Guid("3390BDF4-C974-4211-AA95-3812A8CE7C46"), Text = "Template 2", NodeObjectType = new Guid(Constants.ObjectTypes.Template), CreateDate = DateTime.Now });
|
||||
DatabaseFactory.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99997, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99997", SortOrder = 0, UniqueId = new Guid("BB3241D5-6842-4EFA-A82A-5F56885CF528"), Text = "Test Content Type 1", NodeObjectType = new Guid(Constants.ObjectTypes.DocumentType), CreateDate = DateTime.Now });
|
||||
DatabaseFactory.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99998, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99998", SortOrder = 0, UniqueId = new Guid("EEA66B06-302E-49BA-A8B2-EDF07248BC59"), Text = "Test Content Type 2", NodeObjectType = new Guid(Constants.ObjectTypes.DocumentType), CreateDate = DateTime.Now });
|
||||
DatabaseFactory.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99999, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99999", SortOrder = 0, UniqueId = new Guid("C45CC083-BB27-4C1C-B448-6F703CC9B799"), Text = "Test Content Type 2", NodeObjectType = new Guid(Constants.ObjectTypes.DocumentType), CreateDate = DateTime.Now });
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsTemplate"))));
|
||||
DatabaseContext.Database.Insert("cmsTemplate", "pk", false, new TemplateDto { NodeId = 55554, Alias = "testTemplate1", Design = "", PrimaryKey = 22221});
|
||||
DatabaseContext.Database.Insert("cmsTemplate", "pk", false, new TemplateDto { NodeId = 55555, Alias = "testTemplate2", Design = "", PrimaryKey = 22222 });
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsTemplate"))));
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsTemplate"))));
|
||||
DatabaseFactory.Database.Insert("cmsTemplate", "pk", false, new TemplateDto { NodeId = 55554, Alias = "testTemplate1", Design = "", PrimaryKey = 22221});
|
||||
DatabaseFactory.Database.Insert("cmsTemplate", "pk", false, new TemplateDto { NodeId = 55555, Alias = "testTemplate2", Design = "", PrimaryKey = 22222 });
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsTemplate"))));
|
||||
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
DatabaseContext.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88887, NodeId = 99997, Alias = "TestContentType1", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseContext.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88888, NodeId = 99998, Alias = "TestContentType2", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseContext.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88889, NodeId = 99999, Alias = "TestContentType3", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
DatabaseFactory.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88887, NodeId = 99997, Alias = "TestContentType1", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseFactory.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88888, NodeId = 99998, Alias = "TestContentType2", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseFactory.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88889, NodeId = 99999, Alias = "TestContentType3", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
|
||||
DatabaseContext.Database.Insert(new ContentTypeTemplateDto { ContentTypeNodeId = 99997, IsDefault = true, TemplateNodeId = 55555 });
|
||||
DatabaseContext.Database.Insert(new ContentTypeTemplateDto { ContentTypeNodeId = 99997, IsDefault = false, TemplateNodeId = 55554 });
|
||||
DatabaseFactory.Database.Insert(new ContentTypeTemplateDto { ContentTypeNodeId = 99997, IsDefault = true, TemplateNodeId = 55555 });
|
||||
DatabaseFactory.Database.Insert(new ContentTypeTemplateDto { ContentTypeNodeId = 99997, IsDefault = false, TemplateNodeId = 55554 });
|
||||
|
||||
DatabaseContext.Database.Insert(new ContentTypeAllowedContentTypeDto { AllowedId = 99998, Id = 99997, SortOrder = 1 });
|
||||
DatabaseContext.Database.Insert(new ContentTypeAllowedContentTypeDto { AllowedId = 99999, Id = 99997, SortOrder = 2});
|
||||
DatabaseFactory.Database.Insert(new ContentTypeAllowedContentTypeDto { AllowedId = 99998, Id = 99997, SortOrder = 1 });
|
||||
DatabaseFactory.Database.Insert(new ContentTypeAllowedContentTypeDto { AllowedId = 99999, Id = 99997, SortOrder = 2});
|
||||
|
||||
DatabaseContext.Database.Insert(new ContentType2ContentTypeDto { ChildId = 99999, ParentId = 99997});
|
||||
DatabaseContext.Database.Insert(new ContentType2ContentTypeDto { ChildId = 99998, ParentId = 99997 });
|
||||
DatabaseFactory.Database.Insert(new ContentType2ContentTypeDto { ChildId = 99999, ParentId = 99997});
|
||||
DatabaseFactory.Database.Insert(new ContentType2ContentTypeDto { ChildId = 99998, ParentId = 99997 });
|
||||
|
||||
transaction.Complete();
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
IDictionary<int, List<ContentTypeRepository.ContentTypeQueryMapper.AssociatedTemplate>> allAssociatedTemplates;
|
||||
IDictionary<int, List<int>> allParentContentTypeIds;
|
||||
var contentTypes = ContentTypeRepository.ContentTypeQueryMapper.MapContentTypes(
|
||||
DatabaseContext.Database, SqlSyntax, out allAssociatedTemplates, out allParentContentTypeIds)
|
||||
DatabaseFactory.Database, SqlSyntax, out allAssociatedTemplates, out allParentContentTypeIds)
|
||||
.Where(x => (new[] {99997, 99998}).Contains(x.Id))
|
||||
.ToArray();
|
||||
|
||||
@@ -88,32 +88,32 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
[Test]
|
||||
public void Can_Map_Media_Type_And_Allowed_Types()
|
||||
{
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
DatabaseContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99997, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99997", SortOrder = 0, UniqueId = new Guid("BB3241D5-6842-4EFA-A82A-5F56885CF528"), Text = "Test Media Type 1", NodeObjectType = new Guid(Constants.ObjectTypes.MediaType), CreateDate = DateTime.Now });
|
||||
DatabaseContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99998, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99998", SortOrder = 0, UniqueId = new Guid("EEA66B06-302E-49BA-A8B2-EDF07248BC59"), Text = "Test Media Type 2", NodeObjectType = new Guid(Constants.ObjectTypes.MediaType), CreateDate = DateTime.Now });
|
||||
DatabaseContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99999, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99999", SortOrder = 0, UniqueId = new Guid("C45CC083-BB27-4C1C-B448-6F703CC9B799"), Text = "Test Media Type 2", NodeObjectType = new Guid(Constants.ObjectTypes.MediaType), CreateDate = DateTime.Now });
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
DatabaseFactory.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99997, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99997", SortOrder = 0, UniqueId = new Guid("BB3241D5-6842-4EFA-A82A-5F56885CF528"), Text = "Test Media Type 1", NodeObjectType = new Guid(Constants.ObjectTypes.MediaType), CreateDate = DateTime.Now });
|
||||
DatabaseFactory.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99998, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99998", SortOrder = 0, UniqueId = new Guid("EEA66B06-302E-49BA-A8B2-EDF07248BC59"), Text = "Test Media Type 2", NodeObjectType = new Guid(Constants.ObjectTypes.MediaType), CreateDate = DateTime.Now });
|
||||
DatabaseFactory.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99999, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99999", SortOrder = 0, UniqueId = new Guid("C45CC083-BB27-4C1C-B448-6F703CC9B799"), Text = "Test Media Type 2", NodeObjectType = new Guid(Constants.ObjectTypes.MediaType), CreateDate = DateTime.Now });
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
DatabaseContext.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88887, NodeId = 99997, Alias = "TestContentType1", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseContext.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88888, NodeId = 99998, Alias = "TestContentType2", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseContext.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88889, NodeId = 99999, Alias = "TestContentType3", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
DatabaseFactory.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88887, NodeId = 99997, Alias = "TestContentType1", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseFactory.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88888, NodeId = 99998, Alias = "TestContentType2", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseFactory.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88889, NodeId = 99999, Alias = "TestContentType3", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
|
||||
DatabaseContext.Database.Insert(new ContentTypeAllowedContentTypeDto { AllowedId = 99998, Id = 99997, SortOrder = 1 });
|
||||
DatabaseContext.Database.Insert(new ContentTypeAllowedContentTypeDto { AllowedId = 99999, Id = 99997, SortOrder = 2 });
|
||||
DatabaseFactory.Database.Insert(new ContentTypeAllowedContentTypeDto { AllowedId = 99998, Id = 99997, SortOrder = 1 });
|
||||
DatabaseFactory.Database.Insert(new ContentTypeAllowedContentTypeDto { AllowedId = 99999, Id = 99997, SortOrder = 2 });
|
||||
|
||||
DatabaseContext.Database.Insert(new ContentType2ContentTypeDto { ChildId = 99999, ParentId = 99997 });
|
||||
DatabaseContext.Database.Insert(new ContentType2ContentTypeDto { ChildId = 99998, ParentId = 99997 });
|
||||
DatabaseFactory.Database.Insert(new ContentType2ContentTypeDto { ChildId = 99999, ParentId = 99997 });
|
||||
DatabaseFactory.Database.Insert(new ContentType2ContentTypeDto { ChildId = 99998, ParentId = 99997 });
|
||||
|
||||
transaction.Complete();
|
||||
}
|
||||
|
||||
IDictionary<int, List<int>> allParentContentTypeIds;
|
||||
var contentTypes = ContentTypeRepository.ContentTypeQueryMapper.MapMediaTypes(
|
||||
DatabaseContext.Database, SqlSyntax, out allParentContentTypeIds)
|
||||
DatabaseFactory.Database, SqlSyntax, out allParentContentTypeIds)
|
||||
.Where(x => (new[] { 99997, 99998 }).Contains(x.Id))
|
||||
.ToArray();
|
||||
|
||||
@@ -138,44 +138,44 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
[Test]
|
||||
public void Can_Map_All_Property_Groups_And_Types()
|
||||
{
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
DatabaseContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 55555, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,55555", SortOrder = 1, UniqueId = new Guid("3390BDF4-C974-4211-AA95-3812A8CE7C46"), Text = "Test Data Type", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
DatabaseContext.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99999, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99999", SortOrder = 0, UniqueId = new Guid("129241F0-D24E-4FC3-92D1-BC2D48B7C431"), Text = "Test Content Type", NodeObjectType = new Guid(Constants.ObjectTypes.DocumentType), CreateDate = DateTime.Now });
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
DatabaseFactory.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 55555, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,55555", SortOrder = 1, UniqueId = new Guid("3390BDF4-C974-4211-AA95-3812A8CE7C46"), Text = "Test Data Type", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now });
|
||||
DatabaseFactory.Database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 99999, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,99999", SortOrder = 0, UniqueId = new Guid("129241F0-D24E-4FC3-92D1-BC2D48B7C431"), Text = "Test Content Type", NodeObjectType = new Guid(Constants.ObjectTypes.DocumentType), CreateDate = DateTime.Now });
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsDataType"))));
|
||||
DatabaseContext.Database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 44444, DataTypeId = 55555, PropertyEditorAlias = Constants.PropertyEditors.TextboxAlias, DbType = "Nvarchar" });
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsDataType"))));
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsDataType"))));
|
||||
DatabaseFactory.Database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 44444, DataTypeId = 55555, PropertyEditorAlias = Constants.PropertyEditors.TextboxAlias, DbType = "Nvarchar" });
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsDataType"))));
|
||||
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
DatabaseContext.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88888, NodeId = 99999, Alias = "TestContentType", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
DatabaseFactory.Database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 88888, NodeId = 99999, Alias = "TestContentType", Icon = "icon-folder", Thumbnail = "folder.png", IsContainer = false, AllowAtRoot = true });
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsContentType"))));
|
||||
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsPropertyTypeGroup"))));
|
||||
DatabaseContext.Database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 77776, UniqueId = 77776.ToGuid(), ContentTypeNodeId = 99999, Text = "Group1", SortOrder = 1 });
|
||||
DatabaseContext.Database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 77777, UniqueId = 77777.ToGuid(), ContentTypeNodeId = 99999, Text = "Group2", SortOrder = 2 });
|
||||
DatabaseContext.Database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 77778, UniqueId = 77778.ToGuid(), ContentTypeNodeId = 99999, Text = "Group3", SortOrder = 3 });
|
||||
DatabaseContext.Database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 77779, UniqueId = 77779.ToGuid(), ContentTypeNodeId = 99999, Text = "Group4", SortOrder = 4 });
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsPropertyTypeGroup"))));
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsPropertyTypeGroup"))));
|
||||
DatabaseFactory.Database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 77776, UniqueId = 77776.ToGuid(), ContentTypeNodeId = 99999, Text = "Group1", SortOrder = 1 });
|
||||
DatabaseFactory.Database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 77777, UniqueId = 77777.ToGuid(), ContentTypeNodeId = 99999, Text = "Group2", SortOrder = 2 });
|
||||
DatabaseFactory.Database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 77778, UniqueId = 77778.ToGuid(), ContentTypeNodeId = 99999, Text = "Group3", SortOrder = 3 });
|
||||
DatabaseFactory.Database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 77779, UniqueId = 77779.ToGuid(), ContentTypeNodeId = 99999, Text = "Group4", SortOrder = 4 });
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsPropertyTypeGroup"))));
|
||||
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsPropertyType"))));
|
||||
DatabaseContext.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66662, UniqueId = 66662.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77776, Alias = "property1", Name = "Property 1", SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseContext.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66663, UniqueId = 66663.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77776, Alias = "property2", Name = "Property 2", SortOrder = 1, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseContext.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66664, UniqueId = 66664.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77777, Alias = "property3", Name = "Property 3", SortOrder = 2, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseContext.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66665, UniqueId = 66665.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77777, Alias = "property4", Name = "Property 4", SortOrder = 3, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseContext.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66666, UniqueId = 66666.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = null, Alias = "property5", Name = "Property 5", SortOrder = 4, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseContext.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66667, UniqueId = 66667.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77778, Alias = "property6", Name = "Property 6", SortOrder = 5, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseContext.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66668, UniqueId = 66668.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77778, Alias = "property7", Name = "Property 7", SortOrder = 6, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsPropertyType"))));
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntax.GetQuotedTableName("cmsPropertyType"))));
|
||||
DatabaseFactory.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66662, UniqueId = 66662.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77776, Alias = "property1", Name = "Property 1", SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseFactory.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66663, UniqueId = 66663.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77776, Alias = "property2", Name = "Property 2", SortOrder = 1, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseFactory.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66664, UniqueId = 66664.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77777, Alias = "property3", Name = "Property 3", SortOrder = 2, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseFactory.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66665, UniqueId = 66665.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77777, Alias = "property4", Name = "Property 4", SortOrder = 3, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseFactory.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66666, UniqueId = 66666.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = null, Alias = "property5", Name = "Property 5", SortOrder = 4, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseFactory.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66667, UniqueId = 66667.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77778, Alias = "property6", Name = "Property 6", SortOrder = 5, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseFactory.Database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 66668, UniqueId = 66668.ToGuid(), DataTypeId = 55555, ContentTypeId = 99999, PropertyTypeGroupId = 77778, Alias = "property7", Name = "Property 7", SortOrder = 6, Mandatory = false, ValidationRegExp = null, Description = null });
|
||||
DatabaseFactory.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF ", SqlSyntax.GetQuotedTableName("cmsPropertyType"))));
|
||||
|
||||
transaction.Complete();
|
||||
}
|
||||
|
||||
IDictionary<int, PropertyTypeCollection> allPropTypeCollection;
|
||||
IDictionary<int, PropertyGroupCollection> allPropGroupCollection;
|
||||
ContentTypeRepository.ContentTypeQueryMapper.MapGroupsAndProperties(new[] { 99999 }, DatabaseContext.Database, SqlSyntax, out allPropTypeCollection, out allPropGroupCollection);
|
||||
ContentTypeRepository.ContentTypeQueryMapper.MapGroupsAndProperties(new[] { 99999 }, DatabaseFactory.Database, SqlSyntax, out allPropTypeCollection, out allPropGroupCollection);
|
||||
|
||||
var propGroupCollection = allPropGroupCollection[99999];
|
||||
var propTypeCollection = allPropTypeCollection[99999];
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
|
||||
var dtos = DatabaseContext.Database.Fetch<LogDto>("WHERE id > -1");
|
||||
var dtos = DatabaseFactory.Database.Fetch<LogDto>("WHERE id > -1");
|
||||
|
||||
Assert.That(dtos.Any(), Is.True);
|
||||
Assert.That(dtos.First().Comment, Is.EqualTo("This is a System audit trail"));
|
||||
|
||||
@@ -482,8 +482,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
try
|
||||
{
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlTrace = true;
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlCount = true;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlTrace = true;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlCount = true;
|
||||
|
||||
var result = repository.GetPagedResultsByQuery(query, 0, 2, out totalRecords, "title", Direction.Ascending, false);
|
||||
|
||||
@@ -496,8 +496,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
}
|
||||
finally
|
||||
{
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlTrace = false;
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlCount = false;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlTrace = false;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlCount = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -517,8 +517,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
try
|
||||
{
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlTrace = true;
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlCount = true;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlTrace = true;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlCount = true;
|
||||
var result = repository.GetPagedResultsByQuery(query, 0, 1, out totalRecords, "Name", Direction.Ascending, true);
|
||||
|
||||
// Assert
|
||||
@@ -528,8 +528,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
}
|
||||
finally
|
||||
{
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlTrace = false;
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlCount = false;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlTrace = false;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlCount = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,7 +609,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var contentTypes = repository.GetAll();
|
||||
int count =
|
||||
DatabaseContext.Database.ExecuteScalar<int>(
|
||||
DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM umbracoNode WHERE nodeObjectType = @NodeObjectType",
|
||||
new {NodeObjectType = new Guid(Constants.ObjectTypes.DocumentType)});
|
||||
|
||||
@@ -632,7 +632,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var contentTypes = ((IReadRepository<Guid, IContentType>)repository).GetAll(allGuidIds);
|
||||
int count =
|
||||
DatabaseContext.Database.ExecuteScalar<int>(
|
||||
DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM umbracoNode WHERE nodeObjectType = @NodeObjectType",
|
||||
new { NodeObjectType = new Guid(Constants.ObjectTypes.DocumentType) });
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var mediaTypes = repository.GetAll();
|
||||
int count =
|
||||
DatabaseContext.Database.ExecuteScalar<int>(
|
||||
DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM umbracoNode WHERE nodeObjectType = @NodeObjectType",
|
||||
new {NodeObjectType = new Guid(Constants.ObjectTypes.MediaType)});
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var mediaTypes = ((IReadRepository<Guid, IMediaType>)repository).GetAll(allGuidIds);
|
||||
|
||||
int count =
|
||||
DatabaseContext.Database.ExecuteScalar<int>(
|
||||
DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM umbracoNode WHERE nodeObjectType = @NodeObjectType",
|
||||
new { NodeObjectType = new Guid(Constants.ObjectTypes.MediaType) });
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
if (isCount)
|
||||
{
|
||||
var sqlCount = DatabaseContext.Sql()
|
||||
var sqlCount = DatabaseFactory.Sql()
|
||||
.SelectCount()
|
||||
.From<NodeDto>()
|
||||
.InnerJoin<ContentDto>().On<ContentDto, NodeDto>(left => left.NodeId, right => right.NodeId)
|
||||
@@ -322,7 +322,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
return sqlCount;
|
||||
}
|
||||
|
||||
var sql = DatabaseContext.Sql();
|
||||
var sql = DatabaseFactory.Sql();
|
||||
sql.Select("umbracoNode.*", "cmsContent.contentType", "cmsContentType.alias AS ContentTypeAlias", "cmsContentVersion.VersionId",
|
||||
"cmsContentVersion.VersionDate", "cmsMember.Email",
|
||||
"cmsMember.LoginName", "cmsMember.Password", "cmsPropertyData.id AS PropertyDataId", "cmsPropertyData.propertytypeid",
|
||||
@@ -346,7 +346,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
private Sql<SqlContext> GetSubquery()
|
||||
{
|
||||
var sql = DatabaseContext.Sql();
|
||||
var sql = DatabaseFactory.Sql();
|
||||
sql.Select("umbracoNode.id")
|
||||
.From<NodeDto>()
|
||||
.InnerJoin<ContentDto>().On<ContentDto, NodeDto>(left => left.NodeId, right => right.NodeId)
|
||||
|
||||
@@ -820,7 +820,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
unitOfWork.Flush();
|
||||
|
||||
Assert.AreEqual(0, DatabaseContext.Database.ExecuteScalar<int>(
|
||||
Assert.AreEqual(0, DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM cmsTagRelationship WHERE nodeId=@nodeId AND propertyTypeId=@propTypeId",
|
||||
new { nodeId = content1.Id, propTypeId = contentType.PropertyTypes.First().Id }));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void DatabaseSchemaCreation_Produces_DatabaseSchemaResult_With_Zero_Errors()
|
||||
{
|
||||
// Arrange
|
||||
var db = DatabaseContext.Database;
|
||||
var db = DatabaseFactory.Database;
|
||||
var schema = new DatabaseSchemaCreation(db, Logger);
|
||||
|
||||
// Act
|
||||
|
||||
@@ -14,13 +14,13 @@ namespace Umbraco.Tests.Persistence
|
||||
|
||||
protected DatabaseSchemaHelper DatabaseSchemaHelper
|
||||
{
|
||||
get { return _schemaHelper ?? (_schemaHelper = new DatabaseSchemaHelper(DatabaseContext.Database, Logger)); }
|
||||
get { return _schemaHelper ?? (_schemaHelper = new DatabaseSchemaHelper(DatabaseFactory.Database, Logger)); }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Create_umbracoNode_Table()
|
||||
{
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Umbraco.Tests.Persistence
|
||||
[Test]
|
||||
public void Can_Create_umbracoAccess_Table()
|
||||
{
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<AccessDto>();
|
||||
@@ -43,7 +43,7 @@ namespace Umbraco.Tests.Persistence
|
||||
[Test]
|
||||
public void Can_Create_umbracoAccessRule_Table()
|
||||
{
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<AccessDto>();
|
||||
@@ -57,7 +57,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsContentType2ContentType_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentType2ContentTypeDto>();
|
||||
@@ -70,7 +70,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsContentTypeAllowedContentType_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -84,7 +84,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsContentType_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -97,7 +97,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsContentVersion_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -112,7 +112,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsContentXml_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -127,7 +127,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsDataType_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<DataTypeDto>();
|
||||
@@ -140,7 +140,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsDataTypePreValues_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<DataTypeDto>();
|
||||
@@ -154,7 +154,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsDictionary_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<DictionaryDto>();
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsLanguageText_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<DictionaryDto>();
|
||||
DatabaseSchemaHelper.CreateTable<LanguageDto>();
|
||||
@@ -180,7 +180,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsTemplate_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<TemplateDto>();
|
||||
@@ -193,7 +193,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsDocument_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -209,7 +209,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsDocumentType_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -224,7 +224,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoDomains_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<DomainDto>();
|
||||
@@ -237,7 +237,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoLanguage_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<LanguageDto>();
|
||||
|
||||
@@ -249,7 +249,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoLog_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<LogDto>();
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsMacro_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<MacroDto>();
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsMember_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -288,7 +288,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsMember2MemberGroup_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -304,7 +304,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsMemberType_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -318,7 +318,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsPreviewXml_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -334,7 +334,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsPropertyData_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -351,7 +351,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsPropertyType_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -367,7 +367,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsPropertyTypeGroup_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -381,7 +381,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoRelation_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<RelationTypeDto>();
|
||||
@@ -395,7 +395,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoRelationType_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<RelationTypeDto>();
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsStylesheet_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<StylesheetDto>();
|
||||
@@ -420,7 +420,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsStylesheetProperty_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<StylesheetPropertyDto>();
|
||||
@@ -433,7 +433,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsTags_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<TagDto>();
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsTagRelationship_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<ContentTypeDto>();
|
||||
@@ -465,7 +465,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsTask_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<UserTypeDto>();
|
||||
@@ -481,7 +481,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_cmsTaskType_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<TaskTypeDto>();
|
||||
|
||||
@@ -493,7 +493,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoDeployDependency_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<UmbracoDeployChecksumDto>();
|
||||
DatabaseSchemaHelper.CreateTable<UmbracoDeployDependencyDto>();
|
||||
@@ -506,7 +506,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoDeployChecksum_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<UmbracoDeployChecksumDto>();
|
||||
|
||||
@@ -518,7 +518,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoUser_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<UserTypeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<UserDto>();
|
||||
@@ -531,7 +531,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoUserType_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<UserTypeDto>();
|
||||
|
||||
@@ -543,7 +543,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoUser2app_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<UserTypeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<UserDto>();
|
||||
@@ -557,7 +557,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoUser2NodeNotify_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<UserTypeDto>();
|
||||
@@ -572,7 +572,7 @@ namespace Umbraco.Tests.Persistence
|
||||
public void Can_Create_umbracoUser2NodePermission_Table()
|
||||
{
|
||||
|
||||
using (var transaction = DatabaseContext.Database.GetTransaction())
|
||||
using (var transaction = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
DatabaseSchemaHelper.CreateTable<NodeDto>();
|
||||
DatabaseSchemaHelper.CreateTable<UserTypeDto>();
|
||||
|
||||
@@ -163,7 +163,6 @@ namespace Umbraco.Tests.Runtimes
|
||||
base.Compose(composition);
|
||||
|
||||
composition.Container.Register(factory => SettingsForTests.GetDefault());
|
||||
composition.Container.Register(factory => new DatabaseContext(factory.GetInstance<IUmbracoDatabaseFactory>()), new PerContainerLifetime());
|
||||
composition.Container.RegisterSingleton<IExamineIndexCollectionAccessor, TestIndexCollectionAccessor>();
|
||||
|
||||
Composed = true;
|
||||
|
||||
@@ -522,15 +522,15 @@ namespace Umbraco.Tests.Services
|
||||
// Assert
|
||||
var propertyTypeId = contentType.PropertyTypes.Single(x => x.Alias == "tags").Id;
|
||||
|
||||
Assert.AreEqual(4, DatabaseContext.Database.ExecuteScalar<int>(
|
||||
Assert.AreEqual(4, DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM cmsTagRelationship WHERE nodeId=@nodeId AND propertyTypeId=@propTypeId",
|
||||
new { nodeId = content.Id, propTypeId = propertyTypeId }));
|
||||
|
||||
Assert.AreEqual(3, DatabaseContext.Database.ExecuteScalar<int>(
|
||||
Assert.AreEqual(3, DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM cmsTagRelationship WHERE nodeId=@nodeId AND propertyTypeId=@propTypeId",
|
||||
new { nodeId = child1.Id, propTypeId = propertyTypeId }));
|
||||
|
||||
Assert.AreEqual(2, DatabaseContext.Database.ExecuteScalar<int>(
|
||||
Assert.AreEqual(2, DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM cmsTagRelationship WHERE nodeId=@nodeId AND propertyTypeId=@propTypeId",
|
||||
new { nodeId = child2.Id, propTypeId = propertyTypeId }));
|
||||
}
|
||||
@@ -561,7 +561,7 @@ namespace Umbraco.Tests.Services
|
||||
//the value will have changed but the tags db table will not have
|
||||
Assert.AreEqual(5, content.Properties["tags"].Value.ToString().Split(',').Distinct().Count());
|
||||
var propertyTypeId = contentType.PropertyTypes.Single(x => x.Alias == "tags").Id;
|
||||
Assert.AreEqual(4, DatabaseContext.Database.ExecuteScalar<int>(
|
||||
Assert.AreEqual(4, DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM cmsTagRelationship WHERE nodeId=@nodeId AND propertyTypeId=@propTypeId",
|
||||
new { nodeId = content.Id, propTypeId = propertyTypeId }));
|
||||
}
|
||||
@@ -590,7 +590,7 @@ namespace Umbraco.Tests.Services
|
||||
// Assert
|
||||
Assert.AreEqual(4, content.Properties["tags"].Value.ToString().Split(',').Distinct().Count());
|
||||
var propertyTypeId = contentType.PropertyTypes.Single(x => x.Alias == "tags").Id;
|
||||
Assert.AreEqual(4, DatabaseContext.Database.ExecuteScalar<int>(
|
||||
Assert.AreEqual(4, DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM cmsTagRelationship WHERE nodeId=@nodeId AND propertyTypeId=@propTypeId",
|
||||
new {nodeId = content.Id, propTypeId = propertyTypeId}));
|
||||
}
|
||||
@@ -619,7 +619,7 @@ namespace Umbraco.Tests.Services
|
||||
// Assert
|
||||
Assert.AreEqual(5, content.Properties["tags"].Value.ToString().Split(',').Distinct().Count());
|
||||
var propertyTypeId = contentType.PropertyTypes.Single(x => x.Alias == "tags").Id;
|
||||
Assert.AreEqual(5, DatabaseContext.Database.ExecuteScalar<int>(
|
||||
Assert.AreEqual(5, DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM cmsTagRelationship WHERE nodeId=@nodeId AND propertyTypeId=@propTypeId",
|
||||
new { nodeId = content.Id, propTypeId = propertyTypeId }));
|
||||
}
|
||||
@@ -648,7 +648,7 @@ namespace Umbraco.Tests.Services
|
||||
// Assert
|
||||
Assert.AreEqual(2, content.Properties["tags"].Value.ToString().Split(',').Distinct().Count());
|
||||
var propertyTypeId = contentType.PropertyTypes.Single(x => x.Alias == "tags").Id;
|
||||
Assert.AreEqual(2, DatabaseContext.Database.ExecuteScalar<int>(
|
||||
Assert.AreEqual(2, DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(*) FROM cmsTagRelationship WHERE nodeId=@nodeId AND propertyTypeId=@propTypeId",
|
||||
new { nodeId = content.Id, propTypeId = propertyTypeId }));
|
||||
}
|
||||
|
||||
@@ -56,14 +56,14 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
foreach (var c in contentItems1)
|
||||
{
|
||||
var xml = DatabaseContext.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
var xml = DatabaseFactory.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
Assert.IsNotNull(xml);
|
||||
Assert.IsTrue(xml.Xml.StartsWith("<newAlias"));
|
||||
}
|
||||
|
||||
foreach (var c in contentItems2)
|
||||
{
|
||||
var xml = DatabaseContext.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
var xml = DatabaseFactory.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
Assert.IsNotNull(xml);
|
||||
Assert.IsTrue(xml.Xml.StartsWith("<test2")); //should remain the same
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
foreach (var c in contentItems1)
|
||||
{
|
||||
var xml = DatabaseContext.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
var xml = DatabaseFactory.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
Assert.IsNotNull(xml);
|
||||
Assert.IsTrue(xml.Xml.Contains(elementToMatch)); //verify that it is there before we remove the property
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
foreach (var c in contentItems1)
|
||||
{
|
||||
var xml = DatabaseContext.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
var xml = DatabaseFactory.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
Assert.IsNotNull(xml);
|
||||
Assert.IsFalse(xml.Xml.Contains(elementToMatch)); //verify that it is no longer there
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Umbraco.Tests.Services.Importing
|
||||
var mRBasePage = contentTypes.First(x => x.Alias == "MRBasePage");
|
||||
foreach (var propertyType in mRBasePage.PropertyTypes)
|
||||
{
|
||||
var propertyTypeDto = this.DatabaseContext.Database.First<PropertyTypeDto>("WHERE id = @id", new { id = propertyType.Id });
|
||||
var propertyTypeDto = this.DatabaseFactory.Database.First<PropertyTypeDto>("WHERE id = @id", new { id = propertyType.Id });
|
||||
Assert.AreEqual(propertyTypeDto.UniqueId, propertyType.Key);
|
||||
}
|
||||
}
|
||||
@@ -307,7 +307,7 @@ namespace Umbraco.Tests.Services.Importing
|
||||
where (string)doc.Attribute("isDoc") == ""
|
||||
select doc).Count();
|
||||
|
||||
var database = Current.DatabaseContext.Database;
|
||||
var database = Current.DatabaseFactory.Database;
|
||||
var dtos = database.Fetch<DataTypePreValueDto>("WHERE datatypeNodeId = @Id", new { dataTypeDefinitions.First().Id });
|
||||
int preValueId;
|
||||
int.TryParse(contents.First().GetValue<string>("testList"), out preValueId);
|
||||
|
||||
@@ -130,22 +130,22 @@ namespace Umbraco.Tests.Services
|
||||
currParentId = desc1.Key;
|
||||
}
|
||||
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlTrace = true;
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlCount = true;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlTrace = true;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlCount = true;
|
||||
|
||||
var items = ServiceContext.LocalizationService.GetDictionaryItemDescendants(_parentItemGuidId)
|
||||
.ToArray();
|
||||
|
||||
Debug.WriteLine("SQL CALLS: " + DatabaseContext.Database.AsUmbracoDatabase().SqlCount);
|
||||
Debug.WriteLine("SQL CALLS: " + DatabaseFactory.Database.AsUmbracoDatabase().SqlCount);
|
||||
|
||||
Assert.AreEqual(51, items.Length);
|
||||
//there's a call or two to get languages, so apart from that there should only be one call per level
|
||||
Assert.Less(DatabaseContext.Database.AsUmbracoDatabase().SqlCount, 30);
|
||||
Assert.Less(DatabaseFactory.Database.AsUmbracoDatabase().SqlCount, 30);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlTrace = false;
|
||||
DatabaseContext.Database.AsUmbracoDatabase().EnableSqlCount = false;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlTrace = false;
|
||||
DatabaseFactory.Database.AsUmbracoDatabase().EnableSqlCount = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace Umbraco.Tests.Services
|
||||
public void Can_Get_Members_In_Role()
|
||||
{
|
||||
ServiceContext.MemberService.AddRole("MyTestRole1");
|
||||
var roleId = DatabaseContext.Database.ExecuteScalar<int>("SELECT id from umbracoNode where [text] = 'MyTestRole1'");
|
||||
var roleId = DatabaseFactory.Database.ExecuteScalar<int>("SELECT id from umbracoNode where [text] = 'MyTestRole1'");
|
||||
|
||||
IMemberType memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
ServiceContext.MemberTypeService.Save(memberType);
|
||||
@@ -168,8 +168,8 @@ namespace Umbraco.Tests.Services
|
||||
var member2 = MockedMember.CreateSimpleMember(memberType, "test2", "test2@test.com", "pass", "test2");
|
||||
ServiceContext.MemberService.Save(member2);
|
||||
|
||||
DatabaseContext.Database.Insert(new Member2MemberGroupDto {MemberGroup = roleId, Member = member1.Id});
|
||||
DatabaseContext.Database.Insert(new Member2MemberGroupDto { MemberGroup = roleId, Member = member2.Id });
|
||||
DatabaseFactory.Database.Insert(new Member2MemberGroupDto {MemberGroup = roleId, Member = member1.Id});
|
||||
DatabaseFactory.Database.Insert(new Member2MemberGroupDto { MemberGroup = roleId, Member = member2.Id });
|
||||
|
||||
var membersInRole = ServiceContext.MemberService.GetMembersInRole("MyTestRole1");
|
||||
Assert.AreEqual(2, membersInRole.Count());
|
||||
@@ -338,7 +338,7 @@ namespace Umbraco.Tests.Services
|
||||
IMember member = MockedMember.CreateSimpleMember(memberType, "test", "test@test.com", "pass", "test");
|
||||
ServiceContext.MemberService.Save(member);
|
||||
|
||||
var xml = DatabaseContext.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = member.Id });
|
||||
var xml = DatabaseFactory.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = member.Id });
|
||||
Assert.IsNotNull(xml);
|
||||
}
|
||||
|
||||
@@ -1036,14 +1036,14 @@ namespace Umbraco.Tests.Services
|
||||
result.LastLoginDate.TruncateTo(DateTimeExtensions.DateTruncate.Second));
|
||||
|
||||
//now ensure the col is correct
|
||||
var sql = DatabaseContext.Sql().Select("cmsPropertyData.*")
|
||||
var sql = DatabaseFactory.Sql().Select("cmsPropertyData.*")
|
||||
.From<PropertyDataDto>()
|
||||
.InnerJoin<PropertyTypeDto>()
|
||||
.On<PropertyDataDto, PropertyTypeDto>(dto => dto.PropertyTypeId, dto => dto.Id)
|
||||
.Where<PropertyDataDto>(dto => dto.NodeId == member.Id)
|
||||
.Where<PropertyTypeDto>(dto => dto.Alias == Constants.Conventions.Member.LastLoginDate);
|
||||
|
||||
var colResult = DatabaseContext.Database.Fetch<PropertyDataDto>(sql);
|
||||
var colResult = DatabaseFactory.Database.Fetch<PropertyDataDto>(sql);
|
||||
|
||||
Assert.AreEqual(1, colResult.Count);
|
||||
Assert.IsTrue(colResult.First().Date.HasValue);
|
||||
|
||||
@@ -115,13 +115,13 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
foreach (var c in contentItems1)
|
||||
{
|
||||
var xml = DatabaseContext.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
var xml = DatabaseFactory.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
Assert.IsNotNull(xml);
|
||||
Assert.IsTrue(xml.Xml.StartsWith("<newAlias"));
|
||||
}
|
||||
foreach (var c in contentItems2)
|
||||
{
|
||||
var xml = DatabaseContext.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
var xml = DatabaseFactory.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
Assert.IsNotNull(xml);
|
||||
Assert.IsTrue(xml.Xml.StartsWith("<test2")); //should remain the same
|
||||
}
|
||||
@@ -142,7 +142,7 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
foreach (var c in contentItems1)
|
||||
{
|
||||
var xml = DatabaseContext.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
var xml = DatabaseFactory.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
Assert.IsNotNull(xml);
|
||||
Assert.IsTrue(xml.Xml.Contains(elementToMatch)); //verify that it is there before we remove the property
|
||||
}
|
||||
@@ -156,7 +156,7 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
foreach (var c in contentItems1)
|
||||
{
|
||||
var xml = DatabaseContext.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
var xml = DatabaseFactory.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = c.Id });
|
||||
Assert.IsNotNull(xml);
|
||||
Assert.IsFalse(xml.Xml.Contains(elementToMatch)); //verify that it is no longer there
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace Umbraco.Tests.Services
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
//clear all the xml entries
|
||||
DatabaseContext.Database.Execute(@"DELETE FROM cmsContentXml WHERE nodeId IN
|
||||
DatabaseFactory.Database.Execute(@"DELETE FROM cmsContentXml WHERE nodeId IN
|
||||
(SELECT DISTINCT cmsContentXml.nodeId FROM cmsContentXml
|
||||
INNER JOIN cmsContent ON cmsContentXml.nodeId = cmsContent.nodeId)");
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace Umbraco.Tests.Services
|
||||
var xmlItems = nodes.Select(node => new ContentXmlDto { NodeId = node.NodeId, Xml = UpdatedXmlStructure }).ToList();
|
||||
foreach (var xml in xmlItems)
|
||||
{
|
||||
var result = DatabaseContext.Database.Insert(xml);
|
||||
var result = DatabaseFactory.Database.Insert(xml);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ namespace Umbraco.Tests.Services
|
||||
var xmlItems = nodes.Select(node => new ContentXmlDto { NodeId = node.NodeId, Xml = UpdatedXmlStructure }).ToList();
|
||||
foreach (var xml in xmlItems)
|
||||
{
|
||||
var result = DatabaseContext.Database.Update(xml);
|
||||
var result = DatabaseFactory.Database.Update(xml);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,13 +196,13 @@ namespace Umbraco.Tests.Services
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
//clear all the xml entries
|
||||
DatabaseContext.Database.Execute(@"DELETE FROM cmsContentXml WHERE nodeId IN
|
||||
DatabaseFactory.Database.Execute(@"DELETE FROM cmsContentXml WHERE nodeId IN
|
||||
(SELECT DISTINCT cmsContentXml.nodeId FROM cmsContentXml
|
||||
INNER JOIN cmsContent ON cmsContentXml.nodeId = cmsContent.nodeId)");
|
||||
|
||||
//now we insert each record for the ones we've deleted like we do in the content service.
|
||||
var xmlItems = nodes.Select(node => new ContentXmlDto { NodeId = node.NodeId, Xml = UpdatedXmlStructure }).ToList();
|
||||
DatabaseContext.Database.BulkInsertRecordsWithTransaction(xmlItems);
|
||||
DatabaseFactory.Database.BulkInsertRecordsWithTransaction(xmlItems);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,15 +215,15 @@ namespace Umbraco.Tests.Services
|
||||
//now we insert each record for the ones we've deleted like we do in the content service.
|
||||
var xmlItems = nodes.Select(node => new ContentXmlDto { NodeId = node.NodeId, Xml = UpdatedXmlStructure }).ToList();
|
||||
|
||||
using (var tr = DatabaseContext.Database.GetTransaction())
|
||||
using (var tr = DatabaseFactory.Database.GetTransaction())
|
||||
{
|
||||
//clear all the xml entries
|
||||
DatabaseContext.Database.Execute(@"DELETE FROM cmsContentXml WHERE nodeId IN
|
||||
DatabaseFactory.Database.Execute(@"DELETE FROM cmsContentXml WHERE nodeId IN
|
||||
(SELECT DISTINCT cmsContentXml.nodeId FROM cmsContentXml
|
||||
INNER JOIN cmsContent ON cmsContentXml.nodeId = cmsContent.nodeId)");
|
||||
|
||||
|
||||
DatabaseContext.Database.BulkInsertRecords(xmlItems);
|
||||
DatabaseFactory.Database.BulkInsertRecords(xmlItems);
|
||||
|
||||
tr.Complete();
|
||||
}
|
||||
@@ -291,21 +291,21 @@ namespace Umbraco.Tests.Services
|
||||
Path = ""
|
||||
});
|
||||
}
|
||||
DatabaseContext.Database.BulkInsertRecordsWithTransaction(nodes);
|
||||
DatabaseFactory.Database.BulkInsertRecordsWithTransaction(nodes);
|
||||
|
||||
//re-get the nodes with ids
|
||||
var sql = DatabaseContext.Sql();
|
||||
var sql = DatabaseFactory.Sql();
|
||||
sql.SelectAll().From<NodeDto>().Where<NodeDto>(x => x.NodeObjectType == customObjectType);
|
||||
nodes = DatabaseContext.Database.Fetch<NodeDto>(sql);
|
||||
nodes = DatabaseFactory.Database.Fetch<NodeDto>(sql);
|
||||
|
||||
//create the cmsContent data, each with a new content type id (so we can query on it later if needed)
|
||||
var contentTypeId = 0;
|
||||
var cmsContentItems = nodes.Select(node => new ContentDto { NodeId = node.NodeId, ContentTypeId = contentTypeId++ }).ToList();
|
||||
DatabaseContext.Database.BulkInsertRecordsWithTransaction(cmsContentItems);
|
||||
DatabaseFactory.Database.BulkInsertRecordsWithTransaction(cmsContentItems);
|
||||
|
||||
//create the xml data
|
||||
var xmlItems = nodes.Select(node => new ContentXmlDto { NodeId = node.NodeId, Xml = TestXmlStructure }).ToList();
|
||||
DatabaseContext.Database.BulkInsertRecordsWithTransaction(xmlItems);
|
||||
DatabaseFactory.Database.BulkInsertRecordsWithTransaction(xmlItems);
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Tests.Services
|
||||
{
|
||||
var t = new Thread(() =>
|
||||
{
|
||||
using (DatabaseContext.CreateDatabaseScope())
|
||||
using (DatabaseFactory.CreateScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -127,7 +127,7 @@ namespace Umbraco.Tests.Services
|
||||
{
|
||||
var t = new Thread(() =>
|
||||
{
|
||||
using (DatabaseContext.CreateDatabaseScope())
|
||||
using (DatabaseFactory.CreateScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
protected ServiceContext ServiceContext => Core.DI.Current.Services;
|
||||
|
||||
protected DatabaseContext DatabaseContext => Core.DI.Current.DatabaseContext;
|
||||
protected IUmbracoDatabaseFactory DatabaseFactory => Core.DI.Current.DatabaseFactory;
|
||||
|
||||
public override void SetUp()
|
||||
{
|
||||
@@ -101,7 +101,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
[TestFixtureTearDown]
|
||||
public void FixtureTearDown()
|
||||
{
|
||||
RemoveDatabaseFile(Core.DI.Current.HasContainer ? Core.DI.Current.DatabaseContext.Database : null);
|
||||
RemoveDatabaseFile(Core.DI.Current.HasContainer ? Core.DI.Current.DatabaseFactory.Database : null);
|
||||
}
|
||||
|
||||
public override void TearDown()
|
||||
@@ -111,7 +111,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
try
|
||||
{
|
||||
if (Options.Database == UmbracoTestOptions.Database.NewSchemaPerTest)
|
||||
RemoveDatabaseFile(Core.DI.Current.HasContainer ? Core.DI.Current.Container.TryGetInstance<DatabaseContext>()?.Database : null);
|
||||
RemoveDatabaseFile(Core.DI.Current.HasContainer ? Core.DI.Current.Container.TryGetInstance<IUmbracoDatabaseFactory>()?.Database : null);
|
||||
|
||||
AppDomain.CurrentDomain.SetData("DataDirectory", null);
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
if (Options.Database == UmbracoTestOptions.Database.None || Options.Database == UmbracoTestOptions.Database.NewEmptyPerTest)
|
||||
return;
|
||||
|
||||
_databaseScope = Core.DI.Current.DatabaseContext.CreateDatabaseScope();
|
||||
_databaseScope = Core.DI.Current.DatabaseFactory.CreateScope();
|
||||
|
||||
//create the schema and load default data if:
|
||||
// - is the first test in the session
|
||||
@@ -286,7 +286,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|| Options.Database == UmbracoTestOptions.Database.NewSchemaPerTest
|
||||
|| (FirstTestInFixture && Options.Database == UmbracoTestOptions.Database.NewSchemaPerFixture)))
|
||||
{
|
||||
var database = Core.DI.Current.DatabaseContext.Database;
|
||||
var database = Core.DI.Current.DatabaseFactory.Database;
|
||||
var schemaHelper = new DatabaseSchemaHelper(database, Logger);
|
||||
//Create the umbraco database and its base data
|
||||
schemaHelper.CreateDatabaseSchema(Mock.Of<IRuntimeState>(), Mock.Of<IMigrationEntryService>());
|
||||
|
||||
@@ -34,16 +34,6 @@ namespace Umbraco.Tests.Testing.TestingTests
|
||||
Assert.Pass();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Mock_Database_Context()
|
||||
{
|
||||
var databaseFactory = TestObjects.GetDatabaseFactoryMock();
|
||||
|
||||
// ReSharper disable once UnusedVariable
|
||||
var databaseContext = new DatabaseContext(databaseFactory);
|
||||
Assert.Pass();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Mock_Umbraco_Context()
|
||||
{
|
||||
|
||||
@@ -260,7 +260,6 @@ namespace Umbraco.Tests.Testing
|
||||
sqlSyntaxProviders,
|
||||
Logger, f.GetInstance<IDatabaseScopeAccessor>(),
|
||||
Mock.Of<IMapperCollection>()));
|
||||
Container.RegisterSingleton(f => new DatabaseContext(f.GetInstance<IUmbracoDatabaseFactory>()));
|
||||
|
||||
Container.RegisterCollectionBuilder<UrlSegmentProviderCollectionBuilder>(); // empty
|
||||
Container.Register(factory
|
||||
|
||||
@@ -9,6 +9,7 @@ using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Sync;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
@@ -21,9 +22,9 @@ namespace Umbraco.Web
|
||||
public class BatchedDatabaseServerMessenger : DatabaseServerMessenger
|
||||
{
|
||||
public BatchedDatabaseServerMessenger(
|
||||
IRuntimeState runtime, DatabaseContext dbContext, ILogger logger, ProfilingLogger proflog,
|
||||
IRuntimeState runtime, IUmbracoDatabaseFactory databaseFactory, ILogger logger, ProfilingLogger proflog,
|
||||
bool enableDistCalls, DatabaseServerMessengerOptions options)
|
||||
: base(runtime, dbContext, logger, proflog, enableDistCalls, options)
|
||||
: base(runtime, databaseFactory, logger, proflog, enableDistCalls, options)
|
||||
{ }
|
||||
|
||||
// invoked by BatchedDatabaseServerMessengerStartup which is an ApplicationEventHandler
|
||||
@@ -34,7 +35,7 @@ namespace Umbraco.Web
|
||||
UmbracoModule.EndRequest += UmbracoModule_EndRequest;
|
||||
UmbracoModule.RouteAttempt += UmbracoModule_RouteAttempt;
|
||||
|
||||
if (DatabaseContext.CanConnect == false)
|
||||
if (DatabaseFactory.CanConnect == false)
|
||||
{
|
||||
Logger.Warn<BatchedDatabaseServerMessenger>(
|
||||
"Cannot connect to the database, distributed calls will not be enabled for this server.");
|
||||
|
||||
@@ -9,6 +9,7 @@ using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Macros;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Migrations;
|
||||
using Umbraco.Core.Plugins;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
@@ -229,7 +230,7 @@ namespace Umbraco.Web
|
||||
|
||||
public static ServiceContext Services => CoreCurrent.Services;
|
||||
|
||||
public static DatabaseContext DatabaseContext => CoreCurrent.DatabaseContext;
|
||||
public static IUmbracoDatabaseFactory DatabaseFactory => CoreCurrent.DatabaseFactory;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace Umbraco.Web.Editors
|
||||
if (filter.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
//add the default text filter
|
||||
queryFilter = DatabaseContext.Query<IContent>()
|
||||
queryFilter = DatabaseFactory.Query<IContent>()
|
||||
.Where(x => x.Name.Contains(filter));
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Umbraco.Web.Editors
|
||||
if (filter.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
//add the default text filter
|
||||
queryFilter = DatabaseContext.Query<IMedia>()
|
||||
queryFilter = DatabaseFactory.Query<IMedia>()
|
||||
.Where(x => x.Name.Contains(filter));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Web.Install.InstallSteps;
|
||||
using Umbraco.Web.Install.Models;
|
||||
@@ -121,7 +122,7 @@ namespace Umbraco.Web.Install
|
||||
{
|
||||
// we don't have DatabaseProvider anymore... doing it differently
|
||||
//dbProvider = ApplicationContext.Current.DatabaseContext.DatabaseProvider.ToString();
|
||||
dbProvider = GetDbProviderString(Current.DatabaseContext);
|
||||
dbProvider = GetDbProviderString(Current.DatabaseFactory);
|
||||
}
|
||||
|
||||
var check = new org.umbraco.update.CheckForUpgrade();
|
||||
@@ -143,7 +144,7 @@ namespace Umbraco.Web.Install
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetDbProviderString(DatabaseContext context)
|
||||
internal static string GetDbProviderString(IUmbracoDatabaseFactory factory)
|
||||
{
|
||||
var dbProvider = string.Empty;
|
||||
|
||||
@@ -151,7 +152,7 @@ namespace Umbraco.Web.Install
|
||||
//dbProvider = ApplicationContext.Current.DatabaseContext.DatabaseProvider.ToString();
|
||||
//
|
||||
// doing it differently
|
||||
var syntax = context.SqlSyntax;
|
||||
var syntax = factory.SqlSyntax;
|
||||
if (syntax is SqlCeSyntaxProvider)
|
||||
dbProvider = "SqlServerCE";
|
||||
else if (syntax is MySqlSyntaxProvider)
|
||||
|
||||
@@ -5,6 +5,7 @@ using LightInject;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Web.WebApi;
|
||||
@@ -41,7 +42,7 @@ namespace Umbraco.Web.Mvc
|
||||
/// Gets or sets the database context.
|
||||
/// </summary>
|
||||
[Inject]
|
||||
public DatabaseContext DatabaseContext { get; set; }
|
||||
public IUmbracoDatabaseFactory DatabaseFactory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the services context.
|
||||
|
||||
@@ -6,6 +6,7 @@ using Microsoft.Owin;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
@@ -38,7 +39,7 @@ namespace Umbraco.Web.Mvc
|
||||
/// Gets or sets the database context.
|
||||
/// </summary>
|
||||
[Inject]
|
||||
public DatabaseContext DatabaseContext { get; set; }
|
||||
public IUmbracoDatabaseFactory DatabaseFactory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the services context.
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Sync;
|
||||
|
||||
@@ -16,16 +17,16 @@ namespace Umbraco.Web.Scheduling
|
||||
private readonly IUmbracoSettingsSection _settings;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ProfilingLogger _proflog;
|
||||
private readonly DatabaseContext _databaseContext;
|
||||
private readonly IUmbracoDatabaseFactory _databaseFactory;
|
||||
|
||||
public LogScrubber(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
|
||||
IRuntimeState runtime, IAuditService auditService, IUmbracoSettingsSection settings, DatabaseContext databaseContext, ILogger logger, ProfilingLogger proflog)
|
||||
IRuntimeState runtime, IAuditService auditService, IUmbracoSettingsSection settings, IUmbracoDatabaseFactory databaseFactory, ILogger logger, ProfilingLogger proflog)
|
||||
: base(runner, delayMilliseconds, periodMilliseconds)
|
||||
{
|
||||
_runtime = runtime;
|
||||
_auditService = auditService;
|
||||
_settings = settings;
|
||||
_databaseContext = databaseContext;
|
||||
_databaseFactory = databaseFactory;
|
||||
_logger = logger;
|
||||
_proflog = proflog;
|
||||
}
|
||||
@@ -82,7 +83,7 @@ namespace Umbraco.Web.Scheduling
|
||||
}
|
||||
|
||||
// running on a background task, requires a database scope
|
||||
using (_databaseContext.CreateDatabaseScope())
|
||||
using (_databaseFactory.CreateScope())
|
||||
using (_proflog.DebugDuration<LogScrubber>("Log scrubbing executing", "Log scrubbing complete"))
|
||||
{
|
||||
_auditService.CleanLogs(GetLogScrubbingMaximumAge(_settings));
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Sync;
|
||||
using Umbraco.Web.Mvc;
|
||||
@@ -14,17 +15,17 @@ namespace Umbraco.Web.Scheduling
|
||||
{
|
||||
private readonly IRuntimeState _runtime;
|
||||
private readonly IUserService _userService;
|
||||
private readonly DatabaseContext _databaseContext;
|
||||
private readonly IUmbracoDatabaseFactory _databaseFactory;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ProfilingLogger _proflog;
|
||||
|
||||
public ScheduledPublishing(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
|
||||
IRuntimeState runtime, IUserService userService, DatabaseContext databaseContext, ILogger logger, ProfilingLogger proflog)
|
||||
IRuntimeState runtime, IUserService userService, IUmbracoDatabaseFactory databaseFactory, ILogger logger, ProfilingLogger proflog)
|
||||
: base(runner, delayMilliseconds, periodMilliseconds)
|
||||
{
|
||||
_runtime = runtime;
|
||||
_userService = userService;
|
||||
_databaseContext = databaseContext;
|
||||
_databaseFactory = databaseFactory;
|
||||
_logger = logger;
|
||||
_proflog = proflog;
|
||||
}
|
||||
@@ -84,7 +85,7 @@ namespace Umbraco.Web.Scheduling
|
||||
|
||||
// running on a background task, requires a database scope
|
||||
// (GetAuthenticationHeaderValue uses UserService to load the current user, hence requires a database)
|
||||
using (_databaseContext.CreateDatabaseScope())
|
||||
using (_databaseFactory.CreateScope())
|
||||
{
|
||||
//pass custom the authorization header
|
||||
request.Headers.Authorization = AdminTokenAuthorizeAttribute.GetAuthenticationHeaderValue(_userService);
|
||||
|
||||
@@ -4,6 +4,7 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Components;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
@@ -24,7 +25,7 @@ namespace Umbraco.Web.Scheduling
|
||||
private IAuditService _auditService;
|
||||
private ILogger _logger;
|
||||
private ProfilingLogger _proflog;
|
||||
private DatabaseContext _databaseContext;
|
||||
private IUmbracoDatabaseFactory _databaseFactory;
|
||||
|
||||
private BackgroundTaskRunner<IBackgroundTask> _keepAliveRunner;
|
||||
private BackgroundTaskRunner<IBackgroundTask> _publishingRunner;
|
||||
@@ -35,12 +36,12 @@ namespace Umbraco.Web.Scheduling
|
||||
private object _locker = new object();
|
||||
private IBackgroundTask[] _tasks;
|
||||
|
||||
public void Initialize(IRuntimeState runtime, IUserService userService, IAuditService auditService, DatabaseContext databaseContext, ILogger logger, ProfilingLogger proflog)
|
||||
public void Initialize(IRuntimeState runtime, IUserService userService, IAuditService auditService, IUmbracoDatabaseFactory databaseFactory, ILogger logger, ProfilingLogger proflog)
|
||||
{
|
||||
_runtime = runtime;
|
||||
_userService = userService;
|
||||
_auditService = auditService;
|
||||
_databaseContext = databaseContext;
|
||||
_databaseFactory = databaseFactory;
|
||||
_logger = logger;
|
||||
_proflog = proflog;
|
||||
|
||||
@@ -78,9 +79,9 @@ namespace Umbraco.Web.Scheduling
|
||||
var tasks = new List<IBackgroundTask>
|
||||
{
|
||||
new KeepAlive(_keepAliveRunner, 60000, 300000, _runtime, _logger, _proflog),
|
||||
new ScheduledPublishing(_publishingRunner, 60000, 60000, _runtime, _userService, _databaseContext, _logger, _proflog),
|
||||
new ScheduledPublishing(_publishingRunner, 60000, 60000, _runtime, _userService, _databaseFactory, _logger, _proflog),
|
||||
new ScheduledTasks(_tasksRunner, 60000, 60000, _runtime, settings, _logger, _proflog),
|
||||
new LogScrubber(_scrubberRunner, 60000, LogScrubber.GetLogScrubbingInterval(settings, _logger), _runtime, _auditService, settings, _databaseContext, _logger, _proflog)
|
||||
new LogScrubber(_scrubberRunner, 60000, LogScrubber.GetLogScrubbingInterval(settings, _logger), _runtime, _auditService, settings, _databaseFactory, _logger, _proflog)
|
||||
};
|
||||
|
||||
// ping/keepalive
|
||||
|
||||
@@ -8,6 +8,7 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Components;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Changes;
|
||||
using Umbraco.Core.Sync;
|
||||
@@ -39,7 +40,7 @@ namespace Umbraco.Web.Strategies
|
||||
private BackgroundTaskRunner<IBackgroundTask> _backgroundTaskRunner;
|
||||
private bool _started;
|
||||
private TouchServerTask _task;
|
||||
private DatabaseContext _databaseContext;
|
||||
private IUmbracoDatabaseFactory _databaseFactory;
|
||||
|
||||
public override void Compose(Composition composition)
|
||||
{
|
||||
@@ -48,12 +49,12 @@ namespace Umbraco.Web.Strategies
|
||||
composition.SetServerMessenger(factory =>
|
||||
{
|
||||
var runtime = factory.GetInstance<IRuntimeState>();
|
||||
var databaseContext = factory.GetInstance<DatabaseContext>();
|
||||
var databaseFactory = factory.GetInstance<IUmbracoDatabaseFactory>();
|
||||
var logger = factory.GetInstance<ILogger>();
|
||||
var proflog = factory.GetInstance<ProfilingLogger>();
|
||||
|
||||
return new BatchedDatabaseServerMessenger(
|
||||
runtime, databaseContext, logger, proflog,
|
||||
runtime, databaseFactory, logger, proflog,
|
||||
true,
|
||||
//Default options for web including the required callbacks to build caches
|
||||
new DatabaseServerMessengerOptions
|
||||
@@ -95,7 +96,7 @@ namespace Umbraco.Web.Strategies
|
||||
indexer.Value.RebuildIndex();
|
||||
}
|
||||
|
||||
public void Initialize(IRuntimeState runtime, IServerRegistrar serverRegistrar, IServerRegistrationService registrationService, DatabaseContext databaseContext, ILogger logger)
|
||||
public void Initialize(IRuntimeState runtime, IServerRegistrar serverRegistrar, IServerRegistrationService registrationService, IUmbracoDatabaseFactory databaseFactory, ILogger logger)
|
||||
{
|
||||
if (UmbracoConfig.For.UmbracoSettings().DistributedCall.Enabled) return;
|
||||
|
||||
@@ -103,7 +104,7 @@ namespace Umbraco.Web.Strategies
|
||||
if (_registrar == null) throw new Exception("panic: registar.");
|
||||
|
||||
_runtime = runtime;
|
||||
_databaseContext = databaseContext;
|
||||
_databaseFactory = databaseFactory;
|
||||
_logger = logger;
|
||||
_registrationService = registrationService;
|
||||
|
||||
@@ -151,7 +152,7 @@ namespace Umbraco.Web.Strategies
|
||||
var task = new TouchServerTask(_backgroundTaskRunner,
|
||||
15000, //delay before first execution
|
||||
_registrar.Options.RecurringSeconds*1000, //amount of ms between executions
|
||||
svc, _registrar, serverAddress, _databaseContext, _logger);
|
||||
svc, _registrar, serverAddress, _databaseFactory, _logger);
|
||||
|
||||
// perform the rest async, we don't want to block the startup sequence
|
||||
// this will just reoccur on a background thread
|
||||
@@ -166,7 +167,7 @@ namespace Umbraco.Web.Strategies
|
||||
private readonly IServerRegistrationService _svc;
|
||||
private readonly DatabaseServerRegistrar _registrar;
|
||||
private readonly string _serverAddress;
|
||||
private readonly DatabaseContext _databaseContext;
|
||||
private readonly IUmbracoDatabaseFactory _databaseFactory;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
@@ -182,14 +183,14 @@ namespace Umbraco.Web.Strategies
|
||||
/// <param name="logger"></param>
|
||||
/// <remarks>The task will repeat itself periodically. Use this constructor to create a new task.</remarks>
|
||||
public TouchServerTask(IBackgroundTaskRunner<RecurringTaskBase> runner, int delayMilliseconds, int periodMilliseconds,
|
||||
IServerRegistrationService svc, DatabaseServerRegistrar registrar, string serverAddress, DatabaseContext databaseContext, ILogger logger)
|
||||
IServerRegistrationService svc, DatabaseServerRegistrar registrar, string serverAddress, IUmbracoDatabaseFactory databaseFactory, ILogger logger)
|
||||
: base(runner, delayMilliseconds, periodMilliseconds)
|
||||
{
|
||||
if (svc == null) throw new ArgumentNullException(nameof(svc));
|
||||
_svc = svc;
|
||||
_registrar = registrar;
|
||||
_serverAddress = serverAddress;
|
||||
_databaseContext = databaseContext;
|
||||
_databaseFactory = databaseFactory;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -206,7 +207,7 @@ namespace Umbraco.Web.Strategies
|
||||
try
|
||||
{
|
||||
// running on a background task, requires a database scope
|
||||
using (_databaseContext.CreateDatabaseScope())
|
||||
using (_databaseFactory.CreateScope())
|
||||
{
|
||||
_svc.TouchServer(_serverAddress, _svc.CurrentServerIdentity, _registrar.Options.StaleServerTimeout);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Umbraco.Web.UI.Controls
|
||||
|
||||
private bool DoesMacroHaveParameters(int macroId)
|
||||
{
|
||||
return DatabaseContext.Database.ExecuteScalar<int>(string.Format("SELECT COUNT(*) from cmsMacroProperty where macro = {0}", macroId)) > 0;
|
||||
return DatabaseFactory.Database.ExecuteScalar<int>(string.Format("SELECT COUNT(*) from cmsMacroProperty where macro = {0}", macroId)) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Web.UI;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Web.UI.Controls
|
||||
@@ -26,7 +27,7 @@ namespace Umbraco.Web.UI.Controls
|
||||
// fixme inject somehow
|
||||
Logger = Current.Logger;
|
||||
ProfilingLogger = Current.ProfilingLogger;
|
||||
DatabaseContext = Current.DatabaseContext;
|
||||
DatabaseFactory = Current.DatabaseFactory;
|
||||
Services = Current.Services;
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ namespace Umbraco.Web.UI.Controls
|
||||
/// <summary>
|
||||
/// Gets the database context.
|
||||
/// </summary>
|
||||
protected DatabaseContext DatabaseContext { get; }
|
||||
protected IUmbracoDatabaseFactory DatabaseFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the services context.
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Web.UI;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
@@ -36,7 +37,7 @@ namespace Umbraco.Web.UI.Controls
|
||||
// fixme inject somehow
|
||||
Logger = Current.Logger;
|
||||
ProfilingLogger = Current.ProfilingLogger;
|
||||
DatabaseContext = Current.DatabaseContext;
|
||||
DatabaseFactory = Current.DatabaseFactory;
|
||||
Services = Current.Services;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ namespace Umbraco.Web.UI.Controls
|
||||
/// <summary>
|
||||
/// Gets the database context.
|
||||
/// </summary>
|
||||
public DatabaseContext DatabaseContext { get; }
|
||||
public IUmbracoDatabaseFactory DatabaseFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an instance of ClientTools for access to the pages client API.
|
||||
|
||||
@@ -8,6 +8,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
using System.Web.UI;
|
||||
using Umbraco.Core.Persistence;
|
||||
|
||||
namespace Umbraco.Web.UI.Pages
|
||||
{
|
||||
@@ -63,7 +64,7 @@ namespace Umbraco.Web.UI.Pages
|
||||
/// <summary>
|
||||
/// Gets the database context.
|
||||
/// </summary>
|
||||
public DatabaseContext DatabaseContext => Current.DatabaseContext;
|
||||
public IUmbracoDatabaseFactory DatabaseFactory => Current.DatabaseFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an instance of ClientTools for access to the pages client API.
|
||||
|
||||
@@ -13,6 +13,7 @@ using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Core.Collections;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using GlobalSettings = Umbraco.Core.Configuration.GlobalSettings;
|
||||
@@ -55,7 +56,7 @@ namespace Umbraco.Web
|
||||
internal FacadeRouter FacadeRouter { get; set; }
|
||||
|
||||
[Inject]
|
||||
internal DatabaseContext DatabaseContext { get; set; }
|
||||
internal IUmbracoDatabaseFactory DatabaseFactory { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -85,7 +86,7 @@ namespace Umbraco.Web
|
||||
// process
|
||||
|
||||
// create the database scope which will be disposed with http context
|
||||
var scope = DatabaseContext.CreateDatabaseScope();
|
||||
var scope = DatabaseFactory.CreateScope();
|
||||
|
||||
// create the LegacyRequestInitializer
|
||||
// and initialize legacy stuff
|
||||
|
||||
@@ -6,6 +6,7 @@ using Microsoft.Owin;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
@@ -39,7 +40,7 @@ namespace Umbraco.Web.WebApi
|
||||
/// Gets or sets the database context.
|
||||
/// </summary>
|
||||
[Inject]
|
||||
public DatabaseContext DatabaseContext { get; set; }
|
||||
public IUmbracoDatabaseFactory DatabaseFactory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the services context.
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Web.Routing;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
@@ -27,7 +28,7 @@ namespace Umbraco.Web.WebServices
|
||||
// fixme inject somehow
|
||||
Logger = Current.Logger;
|
||||
ProfilingLogger = Current.ProfilingLogger;
|
||||
DatabaseContext = Current.DatabaseContext;
|
||||
DatabaseFactory = Current.DatabaseFactory;
|
||||
Services = Current.Services;
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ namespace Umbraco.Web.WebServices
|
||||
/// <summary>
|
||||
/// Gets the database context.
|
||||
/// </summary>
|
||||
public DatabaseContext DatabaseContext { get; }
|
||||
public IUmbracoDatabaseFactory DatabaseFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the web security helper.
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Web.Services;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
@@ -31,7 +32,7 @@ namespace Umbraco.Web.WebServices
|
||||
// fixme inject somehow
|
||||
Logger = Current.Logger;
|
||||
ProfilingLogger = Current.ProfilingLogger;
|
||||
DatabaseContext = Current.DatabaseContext;
|
||||
DatabaseFactory = Current.DatabaseFactory;
|
||||
Services = Current.Services;
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ namespace Umbraco.Web.WebServices
|
||||
/// <summary>
|
||||
/// Gets the database context.
|
||||
/// </summary>
|
||||
public DatabaseContext DatabaseContext { get; }
|
||||
public IUmbracoDatabaseFactory DatabaseFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the web security helper.
|
||||
|
||||
@@ -1106,7 +1106,7 @@ namespace umbraco
|
||||
XmlDocument xd = new XmlDocument();
|
||||
xd.LoadXml("<preValues/>");
|
||||
|
||||
foreach (var dr in Current.DatabaseContext.Database.Query<dynamic>(
|
||||
foreach (var dr in Current.DatabaseFactory.Database.Query<dynamic>(
|
||||
"Select id, [value] from cmsDataTypeprevalues where DataTypeNodeId = @dataTypeId order by sortorder",
|
||||
new { dataTypeId = DataTypeId }))
|
||||
{
|
||||
@@ -1128,7 +1128,7 @@ namespace umbraco
|
||||
{
|
||||
try
|
||||
{
|
||||
return Current.DatabaseContext.Database.ExecuteScalar<string>(
|
||||
return Current.DatabaseFactory.Database.ExecuteScalar<string>(
|
||||
"select [value] from cmsDataTypePreValues where id = @id",
|
||||
new {id = Id});
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ namespace umbraco
|
||||
var t = Current.ApplicationCache.RuntimeCache.GetCacheItem<template>(
|
||||
string.Format("{0}{1}", CacheKeys.TemplateFrontEndCacheKey, tId), () =>
|
||||
{
|
||||
var templateData = Current.DatabaseContext.Database.FirstOrDefault<dynamic>(
|
||||
var templateData = Current.DatabaseFactory.Database.FirstOrDefault<dynamic>(
|
||||
@"select nodeId, alias, node.parentID as master, text, design
|
||||
from cmsTemplate
|
||||
inner join umbracoNode node on (node.id = cmsTemplate.nodeId)
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace umbraco.dialogs
|
||||
{
|
||||
//exclude built-in memberhip properties from showing up here
|
||||
var exclude = Constants.Conventions.Member.GetStandardPropertyTypeStubs()
|
||||
.Select(x => Current.DatabaseContext.SqlSyntax.GetQuotedValue(x.Key)).ToArray();
|
||||
.Select(x => Current.DatabaseFactory.SqlSyntax.GetQuotedValue(x.Key)).ToArray();
|
||||
|
||||
fieldSql = string.Format(
|
||||
"select distinct alias from cmsPropertyType where alias not in ({0}) order by alias",
|
||||
@@ -64,7 +64,7 @@ namespace umbraco.dialogs
|
||||
fieldPicker.StandardPropertiesLabel = Services.TextService.Localize("templateEditor/standardFields");
|
||||
fieldPicker.CustomPropertiesLabel = Services.TextService.Localize("templateEditor/customFields");
|
||||
|
||||
var dataTypes = DatabaseContext.Database.Fetch<dynamic>(fieldSql);
|
||||
var dataTypes = DatabaseFactory.Database.Fetch<dynamic>(fieldSql);
|
||||
fieldPicker.DataTextField = "alias";
|
||||
fieldPicker.DataValueField = "alias";
|
||||
fieldPicker.DataSource = dataTypes;
|
||||
@@ -75,7 +75,7 @@ namespace umbraco.dialogs
|
||||
altFieldPicker.StandardPropertiesLabel = Services.TextService.Localize("templateEditor/standardFields");
|
||||
altFieldPicker.CustomPropertiesLabel = Services.TextService.Localize("templateEditor/customFields");
|
||||
|
||||
var dataTypes2 = DatabaseContext.Database.Fetch<dynamic>(fieldSql);
|
||||
var dataTypes2 = DatabaseFactory.Database.Fetch<dynamic>(fieldSql);
|
||||
altFieldPicker.DataTextField = "alias";
|
||||
altFieldPicker.DataValueField = "alias";
|
||||
altFieldPicker.DataSource = dataTypes2;
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace umbraco.cms.presentation.settings
|
||||
public string DoesMacroHaveSettings(string macroId)
|
||||
{
|
||||
if (
|
||||
DatabaseContext.Database.ExecuteScalar<int>(string.Format("select 1 from cmsMacroProperty where macro = {0}", macroId)) ==
|
||||
DatabaseFactory.Database.ExecuteScalar<int>(string.Format("select 1 from cmsMacroProperty where macro = {0}", macroId)) ==
|
||||
1)
|
||||
return "1";
|
||||
else
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace umbraco.presentation.webservices
|
||||
|
||||
string dbProvider = string.Empty;
|
||||
if (string.IsNullOrEmpty(global::Umbraco.Core.Configuration.GlobalSettings.ConfigurationStatus) == false)
|
||||
dbProvider = InstallHelper.GetDbProviderString(Current.DatabaseContext);
|
||||
dbProvider = InstallHelper.GetDbProviderString(Current.DatabaseFactory);
|
||||
|
||||
var check = new global::Umbraco.Web.org.umbraco.update.CheckForUpgrade();
|
||||
check.Install(installId,
|
||||
|
||||
@@ -15,6 +15,7 @@ using Lucene.Net.Analysis;
|
||||
using Lucene.Net.Store;
|
||||
using Umbraco.Core.DI;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using IContentService = Umbraco.Core.Services.IContentService;
|
||||
@@ -33,7 +34,7 @@ namespace UmbracoExamine
|
||||
protected IUserService UserService { get; }
|
||||
|
||||
private readonly IEnumerable<IUrlSegmentProvider> _urlSegmentProviders;
|
||||
private readonly DatabaseContext _databaseContext;
|
||||
private readonly IUmbracoDatabaseFactory _databaseFactory;
|
||||
private int? _parentId;
|
||||
|
||||
#region Constructors
|
||||
@@ -47,7 +48,7 @@ namespace UmbracoExamine
|
||||
UserService = Current.Services.UserService;
|
||||
|
||||
_urlSegmentProviders = Current.UrlSegmentProviders;
|
||||
_databaseContext = Current.DatabaseContext;
|
||||
_databaseFactory = Current.DatabaseFactory;
|
||||
|
||||
InitializeQueries();
|
||||
}
|
||||
@@ -94,7 +95,7 @@ namespace UmbracoExamine
|
||||
private void InitializeQueries()
|
||||
{
|
||||
if (_publishedQuery == null)
|
||||
_publishedQuery = _databaseContext.Query<IContent>().Where(x => x.Published);
|
||||
_publishedQuery = _databaseFactory.Query<IContent>().Where(x => x.Published);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -15,6 +15,7 @@ using Examine.LuceneEngine.Providers;
|
||||
using Lucene.Net.Analysis;
|
||||
using Umbraco.Core.DI;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Directory = Lucene.Net.Store.Directory;
|
||||
|
||||
namespace UmbracoExamine
|
||||
@@ -26,7 +27,7 @@ namespace UmbracoExamine
|
||||
public class UmbracoMemberIndexer : BaseUmbracoIndexer
|
||||
{
|
||||
private readonly IMemberService _memberService;
|
||||
private readonly DatabaseContext _databaseContext;
|
||||
private readonly IUmbracoDatabaseFactory _databaseFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
@@ -35,7 +36,7 @@ namespace UmbracoExamine
|
||||
: base()
|
||||
{
|
||||
_memberService = Current.Services.MemberService;
|
||||
_databaseContext = Current.DatabaseContext;
|
||||
_databaseFactory = Current.DatabaseFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -134,7 +135,7 @@ namespace UmbracoExamine
|
||||
|
||||
IMember[] members;
|
||||
|
||||
using (_databaseContext.CreateDatabaseScope())
|
||||
using (_databaseFactory.CreateScope())
|
||||
{
|
||||
if (IndexerData != null && IndexerData.IncludeNodeTypes.Any())
|
||||
{
|
||||
|
||||
@@ -987,7 +987,7 @@ order by level,sortOrder";
|
||||
{
|
||||
var xmlDoc = new XmlDocument();
|
||||
|
||||
var xmlStr = Current.DatabaseContext.Database.ExecuteScalar<string>(
|
||||
var xmlStr = Current.DatabaseFactory.Database.ExecuteScalar<string>(
|
||||
"select xml from cmsPreviewXml where nodeID = @nodeId and versionId = @versionId",
|
||||
new { nodeId = Id, versionId = version });
|
||||
|
||||
@@ -1000,7 +1000,7 @@ order by level,sortOrder";
|
||||
|
||||
protected internal virtual bool PreviewExists(Guid versionId)
|
||||
{
|
||||
return Current.DatabaseContext.Database.ExecuteScalar<int>(
|
||||
return Current.DatabaseFactory.Database.ExecuteScalar<int>(
|
||||
"SELECT COUNT(nodeId) FROM cmsPreviewXml WHERE nodeId=@nodeId and versionId = @versionId",
|
||||
new {nodeId = Id, versionId = versionId}) != 0;
|
||||
|
||||
@@ -1017,7 +1017,7 @@ order by level,sortOrder";
|
||||
var sql = PreviewExists(versionId) ? "UPDATE cmsPreviewXml SET xml = @xml, timestamp = @timestamp WHERE nodeId=@nodeId AND versionId = @versionId"
|
||||
: "INSERT INTO cmsPreviewXml(nodeId, versionId, timestamp, xml) VALUES (@nodeId, @versionId, @timestamp, @xml)";
|
||||
|
||||
Current.DatabaseContext.Database.Execute(
|
||||
Current.DatabaseFactory.Database.Execute(
|
||||
sql, new {nodeId = Id, versionId = versionId, timestamp = DateTime.Now, xml = x.OuterXml});
|
||||
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace umbraco.cms.businesslogic
|
||||
if (_versionDateInitialized) return _versionDate;
|
||||
|
||||
// content & media have a version date in cmsContentVersion that is updated when saved - use it
|
||||
var db = Current.DatabaseContext.Database;
|
||||
var db = Current.DatabaseFactory.Database;
|
||||
_versionDate = db.ExecuteScalar<DateTime>("SELECT versionDate FROM cmsContentVersion WHERE versionId=@versionId",
|
||||
new { @versionId = Version });
|
||||
_versionDateInitialized = true;
|
||||
@@ -260,7 +260,7 @@ namespace umbraco.cms.businesslogic
|
||||
// Delete all data associated with this content
|
||||
this.deleteAllProperties();
|
||||
|
||||
OnDeletedContent(new ContentDeleteEventArgs(Current.DatabaseContext.Database, Id));
|
||||
OnDeletedContent(new ContentDeleteEventArgs(Current.DatabaseFactory.Database, Id));
|
||||
|
||||
// Delete version history
|
||||
using (var sqlHelper = LegacySqlHelper.SqlHelper)
|
||||
|
||||
@@ -1161,7 +1161,7 @@ namespace umbraco.cms.businesslogic
|
||||
{
|
||||
//NOTE Changed from "DocumentType.GetAllAsList().FindAll(dt => dt.MasterContentType == id)" to loading master contenttypes directly from the db.
|
||||
//Related to http://issues.umbraco.org/issue/U4-1714
|
||||
var dtos = Current.DatabaseContext.Database.Fetch<ContentType2ContentTypeDto>("WHERE parentContentTypeId = @Id", new { Id = id });
|
||||
var dtos = Current.DatabaseFactory.Database.Fetch<ContentType2ContentTypeDto>("WHERE parentContentTypeId = @Id", new { Id = id });
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
FlushFromCache(dto.ChildId);
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace umbraco.cms.businesslogic.language
|
||||
/// </remarks>
|
||||
public void Delete()
|
||||
{
|
||||
if (Current.DatabaseContext.Database.ExecuteScalar<int>("SELECT count(id) FROM umbracoDomains where domainDefaultLanguage = @id", new { id = id }) == 0)
|
||||
if (Current.DatabaseFactory.Database.ExecuteScalar<int>("SELECT count(id) FROM umbracoDomains where domainDefaultLanguage = @id", new { id = id }) == 0)
|
||||
{
|
||||
Current.Services.LocalizationService.Delete(LanguageEntity);
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace umbraco.cms.businesslogic.web
|
||||
|
||||
public static void RemoveTemplateFromDocument(int templateId)
|
||||
{
|
||||
Current.DatabaseContext.Database.Execute(
|
||||
Current.DatabaseFactory.Database.Execute(
|
||||
"update cmsDocument set templateId = NULL where templateId = @TemplateId", new {TemplateId = templateId});
|
||||
//We need to clear cache for Documents since this is touching the database directly
|
||||
Current.ApplicationCache.IsolatedRuntimeCache.ClearCache<IContent>();
|
||||
|
||||
Reference in New Issue
Block a user