diff --git a/src/Umbraco.Core/CompositionExtensions_Essentials.cs b/src/Umbraco.Core/CompositionExtensions_Essentials.cs
index dcea789616..550799f4c0 100644
--- a/src/Umbraco.Core/CompositionExtensions_Essentials.cs
+++ b/src/Umbraco.Core/CompositionExtensions_Essentials.cs
@@ -24,7 +24,8 @@ namespace Umbraco.Core
IRuntimeState state,
ITypeFinder typeFinder,
IIOHelper ioHelper,
- IUmbracoVersion umbracoVersion)
+ IUmbracoVersion umbracoVersion,
+ IDbProviderFactoryCreator dbProviderFactoryCreator)
{
composition.RegisterUnique(logger);
composition.RegisterUnique(profiler);
@@ -39,6 +40,7 @@ namespace Umbraco.Core
composition.RegisterUnique(typeFinder);
composition.RegisterUnique(ioHelper);
composition.RegisterUnique(umbracoVersion);
+ composition.RegisterUnique(dbProviderFactoryCreator);
}
}
}
diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs
index 550b1a67dd..06d78d1318 100644
--- a/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs
+++ b/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs
@@ -29,6 +29,7 @@ namespace Umbraco.Core.Migrations.Install
private readonly ILogger _logger;
private readonly IIOHelper _ioHelper;
private readonly IUmbracoVersion _umbracoVersion;
+ private readonly IDbProviderFactoryCreator _dbProviderFactoryCreator;
private DatabaseSchemaResult _databaseSchemaValidationResult;
@@ -44,7 +45,8 @@ namespace Umbraco.Core.Migrations.Install
IMigrationBuilder migrationBuilder,
IKeyValueService keyValueService,
IIOHelper ioHelper,
- IUmbracoVersion umbracoVersion)
+ IUmbracoVersion umbracoVersion,
+ IDbProviderFactoryCreator dbProviderFactoryCreator)
{
_scopeProvider = scopeProvider;
_globalSettings = globalSettings;
@@ -55,6 +57,7 @@ namespace Umbraco.Core.Migrations.Install
_keyValueService = keyValueService;
_ioHelper = ioHelper;
_umbracoVersion = umbracoVersion;
+ _dbProviderFactoryCreator = dbProviderFactoryCreator;
}
#region Status
@@ -99,7 +102,8 @@ namespace Umbraco.Core.Migrations.Install
databaseType, out providerName);
}
- return DbConnectionExtensions.IsConnectionAvailable(connectionString, providerName);
+ var factory = _dbProviderFactoryCreator.CreateFactory(providerName);
+ return DbConnectionExtensions.IsConnectionAvailable(connectionString, factory);
}
internal bool HasSomeNonDefaultUser()
diff --git a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensionsSqlCe.cs b/src/Umbraco.Core/Persistence/NPocoDatabaseExtensionsSqlCe.cs
new file mode 100644
index 0000000000..88ffa792ec
--- /dev/null
+++ b/src/Umbraco.Core/Persistence/NPocoDatabaseExtensionsSqlCe.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Data.SqlServerCe;
+using System.Linq;
+using NPoco;
+using Umbraco.Core.Persistence.SqlSyntax;
+
+namespace Umbraco.Core.Persistence
+{
+ ///
+ /// Provides extension methods to NPoco Database class.
+ ///
+ public static class NPocoDatabaseExtensionsSqlCe
+ {
+
+ ///
+ /// Bulk-insert records using SqlCE TableDirect method.
+ ///
+ /// The type of the records.
+ /// The database.
+ /// The PocoData object corresponding to the record's type.
+ /// The records.
+ /// The number of records that were inserted.
+ internal static int BulkInsertRecordsSqlCe(IUmbracoDatabase database, PocoData pocoData, IEnumerable records)
+ {
+ var columns = pocoData.Columns.ToArray();
+
+ // create command against the original database.Connection
+ using (var command = database.CreateCommand(database.Connection, CommandType.TableDirect, string.Empty))
+ {
+ command.CommandText = pocoData.TableInfo.TableName;
+ command.CommandType = CommandType.TableDirect; // TODO: why repeat?
+ // TODO: not supporting transactions?
+ //cmd.Transaction = GetTypedTransaction(db.Connection.);
+
+ var count = 0;
+ var tCommand = NPocoDatabaseExtensions.GetTypedCommand(command); // execute on the real command
+
+ // seems to cause problems, I think this is primarily used for retrieval, not inserting.
+ // see: https://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcecommand.indexname%28v=vs.100%29.aspx?f=255&MSPPError=-2147217396
+ //tCommand.IndexName = pd.TableInfo.PrimaryKey;
+
+ using (var resultSet = tCommand.ExecuteResultSet(ResultSetOptions.Updatable))
+ {
+ var updatableRecord = resultSet.CreateRecord();
+ foreach (var record in records)
+ {
+ for (var i = 0; i < columns.Length; i++)
+ {
+ // skip the index if this shouldn't be included (i.e. PK)
+ if (NPocoDatabaseExtensions.IncludeColumn(pocoData, columns[i]))
+ {
+ var val = columns[i].Value.GetValue(record);
+ updatableRecord.SetValue(i, val);
+ }
+ }
+ resultSet.Insert(updatableRecord);
+ count++;
+ }
+ }
+
+ return count;
+ }
+ }
+
+
+ }
+}
diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs
index 7e07748839..1ddb2d4c08 100644
--- a/src/Umbraco.Core/Runtime/CoreRuntime.cs
+++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs
@@ -28,7 +28,7 @@ namespace Umbraco.Core.Runtime
private readonly IUmbracoBootPermissionChecker _umbracoBootPermissionChecker;
- public CoreRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IUmbracoBootPermissionChecker umbracoBootPermissionChecker, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
+ public CoreRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IUmbracoBootPermissionChecker umbracoBootPermissionChecker, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo, IDbProviderFactoryCreator dbProviderFactoryCreator)
{
IOHelper = ioHelper;
Configs = configs;
@@ -36,6 +36,7 @@ namespace Umbraco.Core.Runtime
Profiler = profiler;
HostingEnvironment = hostingEnvironment;
BackOfficeInfo = backOfficeInfo;
+ DbProviderFactoryCreator = dbProviderFactoryCreator;
_umbracoBootPermissionChecker = umbracoBootPermissionChecker;
@@ -59,6 +60,7 @@ namespace Umbraco.Core.Runtime
protected ILogger Logger { get; }
protected IBackOfficeInfo BackOfficeInfo { get; }
+ public IDbProviderFactoryCreator DbProviderFactoryCreator { get; }
///
/// Gets the profiler.
@@ -155,7 +157,7 @@ namespace Umbraco.Core.Runtime
// create the composition
composition = new Composition(register, typeLoader, ProfilingLogger, _state, Configs, IOHelper, appCaches);
- composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state, TypeFinder, IOHelper, UmbracoVersion);
+ composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state, TypeFinder, IOHelper, UmbracoVersion, DbProviderFactoryCreator);
// run handlers
RuntimeOptions.DoRuntimeEssentials(composition, appCaches, typeLoader, databaseFactory);
@@ -363,7 +365,7 @@ namespace Umbraco.Core.Runtime
///
/// This is strictly internal, for tests only.
protected internal virtual IUmbracoDatabaseFactory GetDatabaseFactory()
- => new UmbracoDatabaseFactory(Logger, new Lazy(() => _factory.GetInstance()), Configs);
+ => new UmbracoDatabaseFactory(Logger, new Lazy(() => _factory.GetInstance()), Configs, DbProviderFactoryCreator);
#endregion
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 7139167ea3..b08994817d 100755
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -91,7 +91,7 @@
-
+
2.9.0
@@ -200,7 +200,10 @@
+
+
+
@@ -212,6 +215,12 @@
+
+
+
+
+
+
@@ -287,9 +296,6 @@
-
-
-
@@ -340,7 +346,6 @@
-
@@ -355,39 +360,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -407,24 +382,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -432,18 +391,13 @@
-
-
-
-
-
@@ -565,21 +519,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -637,33 +576,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -718,9 +634,6 @@
-
- Component
-
Properties\SolutionInfo.cs
@@ -741,5 +654,11 @@
Umbraco.Infrastructure
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj
index eea225d59c..91c200bdfe 100644
--- a/src/Umbraco.Examine/Umbraco.Examine.csproj
+++ b/src/Umbraco.Examine/Umbraco.Examine.csproj
@@ -56,7 +56,7 @@
all
-
+
3.3.0
runtime; build; native; contentfiles; analyzers
diff --git a/src/Umbraco.Core/Persistence/BulkDataReader.cs b/src/Umbraco.Infrastructure/Persistence/BulkDataReader.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/BulkDataReader.cs
rename to src/Umbraco.Infrastructure/Persistence/BulkDataReader.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/ConstraintAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/ConstraintAttribute.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/ConstraintAttribute.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/ConstraintAttribute.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/ForeignKeyAttribute.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/IndexAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/IndexAttribute.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/IndexAttribute.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/IndexAttribute.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/IndexTypes.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/IndexTypes.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/IndexTypes.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/IndexTypes.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/LengthAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/LengthAttribute.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/LengthAttribute.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/LengthAttribute.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/NullSettingAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/NullSettingAttribute.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/NullSettingAttribute.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/NullSettingAttribute.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/NullSettings.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/NullSettings.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/NullSettings.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/NullSettings.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/PrimaryKeyColumnAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/PrimaryKeyColumnAttribute.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/PrimaryKeyColumnAttribute.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/PrimaryKeyColumnAttribute.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/ReferencesAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/ReferencesAttribute.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/ReferencesAttribute.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/ReferencesAttribute.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/SpecialDbTypeAttribute.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/SpecialDbTypeAttribute.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/SpecialDbTypeAttribute.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/SpecialDbTypeAttribute.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseAnnotations/SpecialDbTypes.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/SpecialDbTypes.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseAnnotations/SpecialDbTypes.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseAnnotations/SpecialDbTypes.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/ColumnDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ColumnDefinition.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/ColumnDefinition.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ColumnDefinition.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/ConstraintDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ConstraintDefinition.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/ConstraintDefinition.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ConstraintDefinition.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/ConstraintType.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ConstraintType.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/ConstraintType.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ConstraintType.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DbIndexDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/DbIndexDefinition.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DbIndexDefinition.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/DbIndexDefinition.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/DefinitionFactory.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DeletionDataDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/DeletionDataDefinition.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/DeletionDataDefinition.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/DeletionDataDefinition.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/ForeignKeyDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ForeignKeyDefinition.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/ForeignKeyDefinition.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ForeignKeyDefinition.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/IndexColumnDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/IndexColumnDefinition.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/IndexColumnDefinition.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/IndexColumnDefinition.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/IndexDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/IndexDefinition.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/IndexDefinition.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/IndexDefinition.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/InsertionDataDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/InsertionDataDefinition.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/InsertionDataDefinition.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/InsertionDataDefinition.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/ModificationType.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ModificationType.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/ModificationType.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/ModificationType.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/SystemMethods.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/SystemMethods.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/SystemMethods.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/SystemMethods.cs
diff --git a/src/Umbraco.Core/Persistence/DatabaseModelDefinitions/TableDefinition.cs b/src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/TableDefinition.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/DatabaseModelDefinitions/TableDefinition.cs
rename to src/Umbraco.Infrastructure/Persistence/DatabaseModelDefinitions/TableDefinition.cs
diff --git a/src/Umbraco.Core/Persistence/DbConnectionExtensions.cs b/src/Umbraco.Infrastructure/Persistence/DbConnectionExtensions.cs
similarity index 81%
rename from src/Umbraco.Core/Persistence/DbConnectionExtensions.cs
rename to src/Umbraco.Infrastructure/Persistence/DbConnectionExtensions.cs
index 835f76f9f9..d137c3ca21 100644
--- a/src/Umbraco.Core/Persistence/DbConnectionExtensions.cs
+++ b/src/Umbraco.Infrastructure/Persistence/DbConnectionExtensions.cs
@@ -2,10 +2,9 @@
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
-using System.Data.SqlServerCe;
using System.Linq;
using StackExchange.Profiling.Data;
-using Umbraco.Core.Composing;
+using Umbraco.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence.FaultHandling;
@@ -28,17 +27,13 @@ namespace Umbraco.Core.Persistence
return Constants.DbProviderNames.SqlServer;
}
- public static bool IsConnectionAvailable(string connectionString, string providerName)
+ public static bool IsConnectionAvailable(string connectionString, DbProviderFactory factory)
{
- if (providerName != Constants.DbProviderNames.SqlCe
- && providerName != Constants.DbProviderNames.SqlServer)
- throw new NotSupportedException($"Provider \"{providerName}\" is not supported.");
- var factory = DbProviderFactories.GetFactory(providerName);
var connection = factory.CreateConnection();
if (connection == null)
- throw new InvalidOperationException($"Could not create a connection for provider \"{providerName}\".");
+ throw new InvalidOperationException($"Could not create a connection for provider \"{factory}\".");
connection.ConnectionString = connectionString;
using (connection)
@@ -47,6 +42,7 @@ namespace Umbraco.Core.Persistence
}
}
+
public static bool IsAvailable(this IDbConnection connection)
{
try
@@ -95,11 +91,13 @@ namespace Umbraco.Core.Persistence
var builder = new SqlConnectionStringBuilder(connection.ConnectionString);
return $"DataSource: {builder.DataSource}, InitialCatalog: {builder.InitialCatalog}";
}
- case SqlCeConnection _:
- {
- var builder = new SqlCeConnectionStringBuilder(connection.ConnectionString);
- return $"DataSource: {builder.DataSource}";
- }
+ // case SqlCeConnection _:
+ // {
+ // var builder = new SqlCeConnectionStringBuilder(connection.ConnectionString);
+ // return $"DataSource: {builder.DataSource}";
+ // }
+ default:
+ throw new NotSupportedException("TODO"); //TODO fix SqlCeConnection
}
}
catch (Exception ex)
diff --git a/src/Umbraco.Core/Persistence/Dtos/NodeDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs
similarity index 98%
rename from src/Umbraco.Core/Persistence/Dtos/NodeDto.cs
rename to src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs
index 5800efb97a..8207d8811d 100644
--- a/src/Umbraco.Core/Persistence/Dtos/NodeDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/NodeDto.cs
@@ -8,7 +8,7 @@ namespace Umbraco.Core.Persistence.Dtos
[TableName(TableName)]
[PrimaryKey("id")]
[ExplicitColumns]
- internal class NodeDto
+ public class NodeDto
{
public const string TableName = Constants.DatabaseSchema.Tables.Node;
public const int NodeIdSeed = 1060;
diff --git a/src/Umbraco.Core/Persistence/Dtos/UserDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Dtos/UserDto.cs
rename to src/Umbraco.Infrastructure/Persistence/Dtos/UserDto.cs
diff --git a/src/Umbraco.Core/Persistence/Dtos/UserGroup2AppDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroup2AppDto.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Dtos/UserGroup2AppDto.cs
rename to src/Umbraco.Infrastructure/Persistence/Dtos/UserGroup2AppDto.cs
diff --git a/src/Umbraco.Core/Persistence/Dtos/UserGroupDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Dtos/UserGroupDto.cs
rename to src/Umbraco.Infrastructure/Persistence/Dtos/UserGroupDto.cs
diff --git a/src/Umbraco.Core/Persistence/Dtos/UserStartNodeDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserStartNodeDto.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Dtos/UserStartNodeDto.cs
rename to src/Umbraco.Infrastructure/Persistence/Dtos/UserStartNodeDto.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/ITransientErrorDetectionStrategy.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/ITransientErrorDetectionStrategy.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/ITransientErrorDetectionStrategy.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/ITransientErrorDetectionStrategy.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/RetryDbConnection.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryDbConnection.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/RetryDbConnection.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryDbConnection.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/RetryLimitExceededException.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryLimitExceededException.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/RetryLimitExceededException.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryLimitExceededException.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/RetryPolicy.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryPolicy.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/RetryPolicy.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryPolicy.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/RetryPolicyFactory.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryPolicyFactory.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/RetryPolicyFactory.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryPolicyFactory.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/RetryStrategy.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryStrategy.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/RetryStrategy.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryStrategy.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/RetryingEventArgs.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryingEventArgs.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/RetryingEventArgs.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/RetryingEventArgs.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/Strategies/ExponentialBackoff.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/ExponentialBackoff.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/Strategies/ExponentialBackoff.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/ExponentialBackoff.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/Strategies/FixedInterval.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/FixedInterval.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/Strategies/FixedInterval.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/FixedInterval.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/Strategies/Incremental.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/Incremental.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/Strategies/Incremental.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/Incremental.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/Strategies/NetworkConnectivityErrorDetectionStrategy.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/NetworkConnectivityErrorDetectionStrategy.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/Strategies/NetworkConnectivityErrorDetectionStrategy.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/NetworkConnectivityErrorDetectionStrategy.cs
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/Strategies/SqlAzureTransientErrorDetectionStrategy.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/SqlAzureTransientErrorDetectionStrategy.cs
similarity index 95%
rename from src/Umbraco.Core/Persistence/FaultHandling/Strategies/SqlAzureTransientErrorDetectionStrategy.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/SqlAzureTransientErrorDetectionStrategy.cs
index 849fd35fad..4e4c7cfefc 100644
--- a/src/Umbraco.Core/Persistence/FaultHandling/Strategies/SqlAzureTransientErrorDetectionStrategy.cs
+++ b/src/Umbraco.Infrastructure/Persistence/FaultHandling/Strategies/SqlAzureTransientErrorDetectionStrategy.cs
@@ -143,14 +143,14 @@ namespace Umbraco.Core.Persistence.FaultHandling.Strategies
{
return true;
}
- else
- {
- EntityException entityException;
- if ((entityException = ex as EntityException) != null)
- {
- return this.IsTransient(entityException.InnerException);
- }
- }
+ // else
+ // {
+ // EntityException entityException;
+ // if ((entityException = ex as EntityException) != null)
+ // {
+ // return this.IsTransient(entityException.InnerException);
+ // }
+ // }
}
return false;
diff --git a/src/Umbraco.Core/Persistence/FaultHandling/ThrottlingCondition.cs b/src/Umbraco.Infrastructure/Persistence/FaultHandling/ThrottlingCondition.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/FaultHandling/ThrottlingCondition.cs
rename to src/Umbraco.Infrastructure/Persistence/FaultHandling/ThrottlingCondition.cs
diff --git a/src/Umbraco.Infrastructure/Persistence/IDbProviderFactoryCreator.cs b/src/Umbraco.Infrastructure/Persistence/IDbProviderFactoryCreator.cs
new file mode 100644
index 0000000000..d88753fa04
--- /dev/null
+++ b/src/Umbraco.Infrastructure/Persistence/IDbProviderFactoryCreator.cs
@@ -0,0 +1,11 @@
+using System.Data.Common;
+using StackExchange.Profiling.Internal;
+
+namespace Umbraco.Core.Persistence
+{
+ public interface IDbProviderFactoryCreator
+ {
+ DbProviderFactory CreateFactory();
+ DbProviderFactory CreateFactory(string providerName);
+ }
+}
diff --git a/src/Umbraco.Core/Persistence/ISqlContext.cs b/src/Umbraco.Infrastructure/Persistence/ISqlContext.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/ISqlContext.cs
rename to src/Umbraco.Infrastructure/Persistence/ISqlContext.cs
diff --git a/src/Umbraco.Core/Persistence/IUmbracoDatabase.cs b/src/Umbraco.Infrastructure/Persistence/IUmbracoDatabase.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/IUmbracoDatabase.cs
rename to src/Umbraco.Infrastructure/Persistence/IUmbracoDatabase.cs
diff --git a/src/Umbraco.Core/Persistence/IUmbracoDatabaseFactory.cs b/src/Umbraco.Infrastructure/Persistence/IUmbracoDatabaseFactory.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/IUmbracoDatabaseFactory.cs
rename to src/Umbraco.Infrastructure/Persistence/IUmbracoDatabaseFactory.cs
diff --git a/src/Umbraco.Core/Persistence/Mappers/BaseMapper.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Mappers/BaseMapper.cs
rename to src/Umbraco.Infrastructure/Persistence/Mappers/BaseMapper.cs
diff --git a/src/Umbraco.Core/Persistence/Mappers/IMapperCollection.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/IMapperCollection.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Mappers/IMapperCollection.cs
rename to src/Umbraco.Infrastructure/Persistence/Mappers/IMapperCollection.cs
diff --git a/src/Umbraco.Core/Persistence/Mappers/MapperCollection.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/MapperCollection.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Mappers/MapperCollection.cs
rename to src/Umbraco.Infrastructure/Persistence/Mappers/MapperCollection.cs
diff --git a/src/Umbraco.Core/Persistence/Mappers/MapperForAttribute.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/MapperForAttribute.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Mappers/MapperForAttribute.cs
rename to src/Umbraco.Infrastructure/Persistence/Mappers/MapperForAttribute.cs
diff --git a/src/Umbraco.Core/Persistence/Mappers/PocoMapper.cs b/src/Umbraco.Infrastructure/Persistence/Mappers/PocoMapper.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Mappers/PocoMapper.cs
rename to src/Umbraco.Infrastructure/Persistence/Mappers/PocoMapper.cs
diff --git a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs b/src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions-Bulk.cs
similarity index 78%
rename from src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs
rename to src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions-Bulk.cs
index 10db1ca18e..d92efcd0b7 100644
--- a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs
+++ b/src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions-Bulk.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
-using System.Data.SqlServerCe;
using System.Linq;
using NPoco;
using Umbraco.Core.Persistence.SqlSyntax;
@@ -26,6 +25,7 @@ namespace Umbraco.Core.Persistence
///
public static void ConfigureNPocoBulkExtensions()
{
+
SqlBulkCopyHelper.SqlConnectionResolver = dbConn => GetTypedConnection(dbConn);
SqlBulkCopyHelper.SqlTransactionResolver = dbTran => GetTypedTransaction(dbTran);
}
@@ -67,14 +67,15 @@ namespace Umbraco.Core.Persistence
var pocoData = database.PocoDataFactory.ForType(typeof(T));
if (pocoData == null) throw new InvalidOperationException("Could not find PocoData for " + typeof(T));
- if (database.DatabaseType.IsSqlCe())
- {
- if (useNativeBulkInsert) return BulkInsertRecordsSqlCe(database, pocoData, recordsA);
- // else, no other choice
- foreach (var record in recordsA)
- database.Insert(record);
- return recordsA.Length;
- }
+ // if (database.DatabaseType.IsSqlCe())
+ // {
+ // if (useNativeBulkInsert) return BulkInsertRecordsSqlCe(database, pocoData, recordsA);
+ // // else, no other choice
+ // foreach (var record in recordsA)
+ // database.Insert(record);
+ // return recordsA.Length;
+ // }
+ //TODO FIX Sql CE
if (database.DatabaseType.IsSqlServer())
{
@@ -166,61 +167,12 @@ namespace Umbraco.Core.Persistence
/// The column.
/// A value indicating whether the column should be part of the bulk-insert.
/// Columns that are primary keys and auto-incremental, or result columns, are excluded from bulk-inserts.
- private static bool IncludeColumn(PocoData pocoData, KeyValuePair column)
+ public static bool IncludeColumn(PocoData pocoData, KeyValuePair column)
{
return column.Value.ResultColumn == false
&& (pocoData.TableInfo.AutoIncrement == false || column.Key != pocoData.TableInfo.PrimaryKey);
}
- ///
- /// Bulk-insert records using SqlCE TableDirect method.
- ///
- /// The type of the records.
- /// The database.
- /// The PocoData object corresponding to the record's type.
- /// The records.
- /// The number of records that were inserted.
- internal static int BulkInsertRecordsSqlCe(IUmbracoDatabase database, PocoData pocoData, IEnumerable records)
- {
- var columns = pocoData.Columns.ToArray();
-
- // create command against the original database.Connection
- using (var command = database.CreateCommand(database.Connection, CommandType.TableDirect, string.Empty))
- {
- command.CommandText = pocoData.TableInfo.TableName;
- command.CommandType = CommandType.TableDirect; // TODO: why repeat?
- // TODO: not supporting transactions?
- //cmd.Transaction = GetTypedTransaction(db.Connection.);
-
- var count = 0;
- var tCommand = GetTypedCommand(command); // execute on the real command
-
- // seems to cause problems, I think this is primarily used for retrieval, not inserting.
- // see: https://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcecommand.indexname%28v=vs.100%29.aspx?f=255&MSPPError=-2147217396
- //tCommand.IndexName = pd.TableInfo.PrimaryKey;
-
- using (var resultSet = tCommand.ExecuteResultSet(ResultSetOptions.Updatable))
- {
- var updatableRecord = resultSet.CreateRecord();
- foreach (var record in records)
- {
- for (var i = 0; i < columns.Length; i++)
- {
- // skip the index if this shouldn't be included (i.e. PK)
- if (IncludeColumn(pocoData, columns[i]))
- {
- var val = columns[i].Value.GetValue(record);
- updatableRecord.SetValue(i, val);
- }
- }
- resultSet.Insert(updatableRecord);
- count++;
- }
- }
-
- return count;
- }
- }
///
/// Bulk-insert records using SqlServer BulkCopy method.
diff --git a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs b/src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs
similarity index 96%
rename from src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs
rename to src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs
index acfa51f895..a2d73c11de 100644
--- a/src/Umbraco.Core/Persistence/NPocoDatabaseExtensions.cs
+++ b/src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data;
-using System.Data.Common;
using System.Data.SqlClient;
-using System.Data.SqlServerCe;
-using System.Linq;
using System.Text.RegularExpressions;
using NPoco;
using StackExchange.Profiling.Data;
@@ -49,7 +46,7 @@ namespace Umbraco.Core.Persistence
/// Note that with proper transactions, if T2 begins after T1 then we are sure that the database will contain T2's value
/// once T1 and T2 have completed. Whereas here, it could contain T1's value.
///
- internal static RecordPersistenceType InsertOrUpdate(this IUmbracoDatabase db, T poco)
+ public static RecordPersistenceType InsertOrUpdate(this IUmbracoDatabase db, T poco)
where T : class
{
return db.InsertOrUpdate(poco, null, null);
@@ -72,7 +69,7 @@ namespace Umbraco.Core.Persistence
/// Note that with proper transactions, if T2 begins after T1 then we are sure that the database will contain T2's value
/// once T1 and T2 have completed. Whereas here, it could contain T1's value.
///
- internal static RecordPersistenceType InsertOrUpdate(this IUmbracoDatabase db,
+ public static RecordPersistenceType InsertOrUpdate(this IUmbracoDatabase db,
T poco,
string updateCommand,
object updateArgs)
@@ -197,7 +194,7 @@ namespace Umbraco.Core.Persistence
///
///
///
- private static TCommand GetTypedCommand(IDbCommand command)
+ public static TCommand GetTypedCommand(IDbCommand command)
where TCommand : class, IDbCommand
{
var c = command;
diff --git a/src/Umbraco.Core/Persistence/NPocoDatabaseTypeExtensions.cs b/src/Umbraco.Infrastructure/Persistence/NPocoDatabaseTypeExtensions.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/NPocoDatabaseTypeExtensions.cs
rename to src/Umbraco.Infrastructure/Persistence/NPocoDatabaseTypeExtensions.cs
diff --git a/src/Umbraco.Core/Persistence/NPocoSqlExtensions.cs b/src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs
similarity index 99%
rename from src/Umbraco.Core/Persistence/NPocoSqlExtensions.cs
rename to src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs
index ff3590439a..c8c1aba75c 100644
--- a/src/Umbraco.Core/Persistence/NPocoSqlExtensions.cs
+++ b/src/Umbraco.Infrastructure/Persistence/NPocoSqlExtensions.cs
@@ -1165,19 +1165,19 @@ namespace Umbraco.Core.Persistence
return string.IsNullOrWhiteSpace(attr?.Name) ? column.Name : attr.Name;
}
- internal static string ToText(this Sql sql)
+ public static string ToText(this Sql sql)
{
var text = new StringBuilder();
sql.ToText(text);
return text.ToString();
}
- internal static void ToText(this Sql sql, StringBuilder text)
+ public static void ToText(this Sql sql, StringBuilder text)
{
ToText(sql.SQL, sql.Arguments, text);
}
- internal static void ToText(string sql, object[] arguments, StringBuilder text)
+ public static void ToText(string sql, object[] arguments, StringBuilder text)
{
text.AppendLine(sql);
diff --git a/src/Umbraco.Core/Persistence/PocoDataDataReader.cs b/src/Umbraco.Infrastructure/Persistence/PocoDataDataReader.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/PocoDataDataReader.cs
rename to src/Umbraco.Infrastructure/Persistence/PocoDataDataReader.cs
diff --git a/src/Umbraco.Core/Persistence/Querying/CachedExpression.cs b/src/Umbraco.Infrastructure/Persistence/Querying/CachedExpression.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Querying/CachedExpression.cs
rename to src/Umbraco.Infrastructure/Persistence/Querying/CachedExpression.cs
diff --git a/src/Umbraco.Core/Persistence/Querying/ExpressionVisitorBase.cs b/src/Umbraco.Infrastructure/Persistence/Querying/ExpressionVisitorBase.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Querying/ExpressionVisitorBase.cs
rename to src/Umbraco.Infrastructure/Persistence/Querying/ExpressionVisitorBase.cs
diff --git a/src/Umbraco.Core/Persistence/Querying/ModelToSqlExpressionVisitor.cs b/src/Umbraco.Infrastructure/Persistence/Querying/ModelToSqlExpressionVisitor.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Querying/ModelToSqlExpressionVisitor.cs
rename to src/Umbraco.Infrastructure/Persistence/Querying/ModelToSqlExpressionVisitor.cs
diff --git a/src/Umbraco.Core/Persistence/Querying/PocoToSqlExpressionVisitor.cs b/src/Umbraco.Infrastructure/Persistence/Querying/PocoToSqlExpressionVisitor.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Querying/PocoToSqlExpressionVisitor.cs
rename to src/Umbraco.Infrastructure/Persistence/Querying/PocoToSqlExpressionVisitor.cs
diff --git a/src/Umbraco.Core/Persistence/Querying/Query.cs b/src/Umbraco.Infrastructure/Persistence/Querying/Query.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Querying/Query.cs
rename to src/Umbraco.Infrastructure/Persistence/Querying/Query.cs
diff --git a/src/Umbraco.Core/Persistence/Querying/QueryExtensions.cs b/src/Umbraco.Infrastructure/Persistence/Querying/QueryExtensions.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Querying/QueryExtensions.cs
rename to src/Umbraco.Infrastructure/Persistence/Querying/QueryExtensions.cs
diff --git a/src/Umbraco.Core/Persistence/Querying/SqlExpressionExtensions.cs b/src/Umbraco.Infrastructure/Persistence/Querying/SqlExpressionExtensions.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Querying/SqlExpressionExtensions.cs
rename to src/Umbraco.Infrastructure/Persistence/Querying/SqlExpressionExtensions.cs
diff --git a/src/Umbraco.Core/Persistence/Querying/SqlTranslator.cs b/src/Umbraco.Infrastructure/Persistence/Querying/SqlTranslator.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Querying/SqlTranslator.cs
rename to src/Umbraco.Infrastructure/Persistence/Querying/SqlTranslator.cs
diff --git a/src/Umbraco.Core/Persistence/Querying/TextColumnType.cs b/src/Umbraco.Infrastructure/Persistence/Querying/TextColumnType.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/Querying/TextColumnType.cs
rename to src/Umbraco.Infrastructure/Persistence/Querying/TextColumnType.cs
diff --git a/src/Umbraco.Core/Persistence/RecordPersistenceType.cs b/src/Umbraco.Infrastructure/Persistence/RecordPersistenceType.cs
similarity index 71%
rename from src/Umbraco.Core/Persistence/RecordPersistenceType.cs
rename to src/Umbraco.Infrastructure/Persistence/RecordPersistenceType.cs
index 3eb94c70ae..8fd29aabaf 100644
--- a/src/Umbraco.Core/Persistence/RecordPersistenceType.cs
+++ b/src/Umbraco.Infrastructure/Persistence/RecordPersistenceType.cs
@@ -1,6 +1,6 @@
namespace Umbraco.Core.Persistence
{
- internal enum RecordPersistenceType
+ public enum RecordPersistenceType
{
Insert,
Update,
diff --git a/src/Umbraco.Core/Persistence/SqlContext.cs b/src/Umbraco.Infrastructure/Persistence/SqlContext.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlContext.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlContext.cs
diff --git a/src/Umbraco.Core/Persistence/SqlContextExtensions.cs b/src/Umbraco.Infrastructure/Persistence/SqlContextExtensions.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlContextExtensions.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlContextExtensions.cs
diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/ColumnInfo.cs b/src/Umbraco.Infrastructure/Persistence/SqlSyntax/ColumnInfo.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlSyntax/ColumnInfo.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlSyntax/ColumnInfo.cs
diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/DbTypes.cs b/src/Umbraco.Infrastructure/Persistence/SqlSyntax/DbTypes.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlSyntax/DbTypes.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlSyntax/DbTypes.cs
diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/ISqlSyntaxProvider.cs b/src/Umbraco.Infrastructure/Persistence/SqlSyntax/ISqlSyntaxProvider.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlSyntax/ISqlSyntaxProvider.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlSyntax/ISqlSyntaxProvider.cs
diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/MicrosoftSqlSyntaxProviderBase.cs b/src/Umbraco.Infrastructure/Persistence/SqlSyntax/MicrosoftSqlSyntaxProviderBase.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlSyntax/MicrosoftSqlSyntaxProviderBase.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlSyntax/MicrosoftSqlSyntaxProviderBase.cs
diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/SqlServerSyntaxProvider.cs b/src/Umbraco.Infrastructure/Persistence/SqlSyntax/SqlServerSyntaxProvider.cs
similarity index 97%
rename from src/Umbraco.Core/Persistence/SqlSyntax/SqlServerSyntaxProvider.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlSyntax/SqlServerSyntaxProvider.cs
index 3d0adf175e..37375ef25d 100644
--- a/src/Umbraco.Core/Persistence/SqlSyntax/SqlServerSyntaxProvider.cs
+++ b/src/Umbraco.Infrastructure/Persistence/SqlSyntax/SqlServerSyntaxProvider.cs
@@ -16,9 +16,9 @@ namespace Umbraco.Core.Persistence.SqlSyntax
///
public class SqlServerSyntaxProvider : MicrosoftSqlSyntaxProviderBase
{
- internal ServerVersionInfo ServerVersion { get; private set; }
+ public ServerVersionInfo ServerVersion { get; private set; }
- internal enum VersionName
+ public enum VersionName
{
Invalid = -1,
Unknown = 0,
@@ -33,7 +33,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
Other = 99
}
- internal enum EngineEdition
+ public enum EngineEdition
{
Unknown = 0,
Desktop = 1,
@@ -43,7 +43,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
Azure = 5
}
- internal class ServerVersionInfo
+ public class ServerVersionInfo
{
public ServerVersionInfo()
{
@@ -102,7 +102,8 @@ namespace Umbraco.Core.Persistence.SqlSyntax
internal ServerVersionInfo GetSetVersion(string connectionString, string providerName, ILogger logger)
{
- var factory = DbProviderFactories.GetFactory(providerName);
+ //var factory = DbProviderFactories.GetFactory(providerName);
+ var factory = SqlClientFactory.Instance;
var connection = factory.CreateConnection();
if (connection == null)
diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/SqlServerVersionName.cs b/src/Umbraco.Infrastructure/Persistence/SqlSyntax/SqlServerVersionName.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlSyntax/SqlServerVersionName.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlSyntax/SqlServerVersionName.cs
diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/SqlSyntaxProviderBase.cs b/src/Umbraco.Infrastructure/Persistence/SqlSyntax/SqlSyntaxProviderBase.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlSyntax/SqlSyntaxProviderBase.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlSyntax/SqlSyntaxProviderBase.cs
diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/SqlSyntaxProviderExtensions.cs b/src/Umbraco.Infrastructure/Persistence/SqlSyntax/SqlSyntaxProviderExtensions.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlSyntax/SqlSyntaxProviderExtensions.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlSyntax/SqlSyntaxProviderExtensions.cs
diff --git a/src/Umbraco.Core/Persistence/SqlSyntaxExtensions.cs b/src/Umbraco.Infrastructure/Persistence/SqlSyntaxExtensions.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlSyntaxExtensions.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlSyntaxExtensions.cs
diff --git a/src/Umbraco.Core/Persistence/SqlTemplate.cs b/src/Umbraco.Infrastructure/Persistence/SqlTemplate.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlTemplate.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlTemplate.cs
diff --git a/src/Umbraco.Core/Persistence/SqlTemplates.cs b/src/Umbraco.Infrastructure/Persistence/SqlTemplates.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/SqlTemplates.cs
rename to src/Umbraco.Infrastructure/Persistence/SqlTemplates.cs
diff --git a/src/Umbraco.Core/Persistence/UmbracoDatabase.cs b/src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/UmbracoDatabase.cs
rename to src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs
diff --git a/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs b/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs
similarity index 93%
rename from src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs
rename to src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs
index 2a1aa7d6dc..20111f6cb0 100644
--- a/src/Umbraco.Core/Persistence/UmbracoDatabaseFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs
@@ -1,5 +1,6 @@
using System;
using System.Data.Common;
+using System.Data.SqlClient;
using System.Threading;
using NPoco;
using NPoco.FluentMappings;
@@ -26,6 +27,8 @@ namespace Umbraco.Core.Persistence
// TODO: this class needs not be disposable!
internal class UmbracoDatabaseFactory : DisposableObjectSlim, IUmbracoDatabaseFactory
{
+ private readonly Configs _configs;
+ private readonly IDbProviderFactoryCreator _dbProviderFactoryCreator;
private readonly Lazy _mappers;
private readonly ILogger _logger;
@@ -51,20 +54,24 @@ namespace Umbraco.Core.Persistence
/// Initializes a new instance of the .
///
/// Used by core runtime.
- public UmbracoDatabaseFactory(ILogger logger, Lazy mappers, Configs configs)
- : this(Constants.System.UmbracoConnectionName, logger, mappers, configs)
- { }
+ public UmbracoDatabaseFactory(ILogger logger, Lazy mappers, Configs configs, IDbProviderFactoryCreator dbProviderFactoryCreator)
+ : this(Constants.System.UmbracoConnectionName, logger, mappers, configs, dbProviderFactoryCreator)
+ {
+ _configs = configs;
+ }
///
/// Initializes a new instance of the .
///
/// Used by the other ctor and in tests.
- public UmbracoDatabaseFactory(string connectionStringName, ILogger logger, Lazy mappers, Configs configs)
+ public UmbracoDatabaseFactory(string connectionStringName, ILogger logger, Lazy mappers, Configs configs, IDbProviderFactoryCreator dbProviderFactoryCreator)
{
if (connectionStringName == null) throw new ArgumentNullException(nameof(connectionStringName));
if (string.IsNullOrWhiteSpace(connectionStringName)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(connectionStringName));
_mappers = mappers ?? throw new ArgumentNullException(nameof(mappers));
+ _configs = configs;
+ _dbProviderFactoryCreator = dbProviderFactoryCreator ?? throw new ArgumentNullException(nameof(dbProviderFactoryCreator));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
var settings = configs.ConnectionStrings()[connectionStringName];
@@ -130,13 +137,13 @@ namespace Umbraco.Core.Persistence
public bool CanConnect =>
// actually tries to connect to the database (regardless of configured/initialized)
!_connectionString.IsNullOrWhiteSpace() && !_providerName.IsNullOrWhiteSpace() &&
- DbConnectionExtensions.IsConnectionAvailable(_connectionString, _providerName);
+ DbConnectionExtensions.IsConnectionAvailable(_connectionString, _dbProviderFactory);
private void UpdateSqlServerDatabaseType()
{
// replace NPoco database type by a more efficient one
- var setting = Current.Configs.Global().DatabaseFactoryServerVersion;
+ var setting = _configs.Global().DatabaseFactoryServerVersion;
var fromSettings = false;
if (setting.IsNullOrWhiteSpace() || !setting.StartsWith("SqlServer.")
@@ -214,16 +221,18 @@ namespace Umbraco.Core.Persistence
if (_connectionString.IsNullOrWhiteSpace()) throw new InvalidOperationException("The factory has not been configured with a proper connection string.");
if (_providerName.IsNullOrWhiteSpace()) throw new InvalidOperationException("The factory has not been configured with a proper provider name.");
+ _dbProviderFactory = _dbProviderFactoryCreator.CreateFactory(_providerName);
+ if (_dbProviderFactory == null)
+ throw new Exception($"Can't find a provider factory for provider name \"{_providerName}\".");
+
// cannot initialize without being able to talk to the database
- if (!DbConnectionExtensions.IsConnectionAvailable(_connectionString, _providerName))
+ if (!DbConnectionExtensions.IsConnectionAvailable(_connectionString, _dbProviderFactory))
throw new Exception("Cannot connect to the database.");
_connectionRetryPolicy = RetryPolicyFactory.GetDefaultSqlConnectionRetryPolicyByConnectionString(_connectionString);
_commandRetryPolicy = RetryPolicyFactory.GetDefaultSqlCommandRetryPolicyByConnectionString(_connectionString);
- _dbProviderFactory = DbProviderFactories.GetFactory(_providerName);
- if (_dbProviderFactory == null)
- throw new Exception($"Can't find a provider factory for provider name \"{_providerName}\".");
+
_databaseType = DatabaseType.Resolve(_dbProviderFactory.GetType().Name, _providerName);
if (_databaseType == null)
throw new Exception($"Can't find an NPoco database type for provider name \"{_providerName}\".");
@@ -272,8 +281,8 @@ namespace Umbraco.Core.Persistence
{
switch (providerName)
{
- case Constants.DbProviderNames.SqlCe:
- return new SqlCeSyntaxProvider();
+ // case Constants.DbProviderNames.SqlCe:
+ // return new SqlCeSyntaxProvider();
case Constants.DbProviderNames.SqlServer:
return new SqlServerSyntaxProvider();
default:
diff --git a/src/Umbraco.Core/Persistence/UmbracoPocoDataBuilder.cs b/src/Umbraco.Infrastructure/Persistence/UmbracoPocoDataBuilder.cs
similarity index 100%
rename from src/Umbraco.Core/Persistence/UmbracoPocoDataBuilder.cs
rename to src/Umbraco.Infrastructure/Persistence/UmbracoPocoDataBuilder.cs
diff --git a/src/Umbraco.Core/Scoping/IScope.cs b/src/Umbraco.Infrastructure/Scoping/IScope.cs
similarity index 100%
rename from src/Umbraco.Core/Scoping/IScope.cs
rename to src/Umbraco.Infrastructure/Scoping/IScope.cs
diff --git a/src/Umbraco.Core/Scoping/IScopeProvider.cs b/src/Umbraco.Infrastructure/Scoping/IScopeProvider.cs
similarity index 100%
rename from src/Umbraco.Core/Scoping/IScopeProvider.cs
rename to src/Umbraco.Infrastructure/Scoping/IScopeProvider.cs
diff --git a/src/Umbraco.Core/Scoping/RepositoryCacheMode.cs b/src/Umbraco.Infrastructure/Scoping/RepositoryCacheMode.cs
similarity index 100%
rename from src/Umbraco.Core/Scoping/RepositoryCacheMode.cs
rename to src/Umbraco.Infrastructure/Scoping/RepositoryCacheMode.cs
diff --git a/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj b/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj
index 68a184dd25..3a6b8387f2 100644
--- a/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj
+++ b/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj
@@ -7,6 +7,7 @@
+
@@ -20,6 +21,7 @@
+
@@ -31,49 +33,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -103,11 +66,6 @@
-
-
-
-
-
diff --git a/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj b/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj
index 8ccb49b67c..97a2ef35ba 100644
--- a/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj
+++ b/src/Umbraco.Tests.Benchmarks/Umbraco.Tests.Benchmarks.csproj
@@ -79,6 +79,10 @@
{07fbc26b-2927-4a22-8d96-d644c667fecc}
Umbraco.Examine
+
+ {3ae7bf57-966b-45a5-910a-954d7c554441}
+ Umbraco.Infrastructure
+
{5d3b8245-ada6-453f-a008-50ed04bfe770}
Umbraco.Tests
diff --git a/src/Umbraco.Tests/App.config b/src/Umbraco.Tests/App.config
index 812e4383de..09c025aeb4 100644
--- a/src/Umbraco.Tests/App.config
+++ b/src/Umbraco.Tests/App.config
@@ -97,6 +97,10 @@
+
+
+
+
diff --git a/src/Umbraco.Tests/Components/ComponentTests.cs b/src/Umbraco.Tests/Components/ComponentTests.cs
index 4733b2c338..2196a4c276 100644
--- a/src/Umbraco.Tests/Components/ComponentTests.cs
+++ b/src/Umbraco.Tests/Components/ComponentTests.cs
@@ -36,7 +36,7 @@ namespace Umbraco.Tests.Components
var logger = Mock.Of();
var typeFinder = new TypeFinder(logger);
- var f = new UmbracoDatabaseFactory(logger, new Lazy(() => new MapperCollection(Enumerable.Empty())), TestHelper.GetConfigs());
+ var f = new UmbracoDatabaseFactory(logger, new Lazy(() => new MapperCollection(Enumerable.Empty())), TestHelper.GetConfigs(), TestHelper.DbProviderFactoryCreator);
var fs = new FileSystems(mock.Object, logger, TestHelper.IOHelper, SettingsForTests.GenerateMockGlobalSettings());
var p = new ScopeProvider(f, fs, logger, typeFinder, NoAppCache.Instance);
diff --git a/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs b/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs
index 120ec6bc72..8ffb5a67d3 100644
--- a/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs
+++ b/src/Umbraco.Tests/Persistence/DatabaseContextTests.cs
@@ -37,7 +37,7 @@ namespace Umbraco.Tests.Persistence
_sqlSyntaxProviders = new[] { (ISqlSyntaxProvider) _sqlCeSyntaxProvider };
_logger = Mock.Of();
_umbracoVersion = TestHelper.GetUmbracoVersion();
- _databaseFactory = new UmbracoDatabaseFactory(_logger, new Lazy(() => Mock.Of()), TestHelper.GetConfigs());
+ _databaseFactory = new UmbracoDatabaseFactory(_logger, new Lazy(() => Mock.Of()), TestHelper.GetConfigs(), TestHelper.DbProviderFactoryCreator);
}
[TearDown]
diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
index 3994ff9c6e..6e9dd50aac 100644
--- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
+++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs
@@ -53,7 +53,7 @@ namespace Umbraco.Tests.Routing
public class TestRuntime : WebRuntime
{
public TestRuntime(UmbracoApplicationBase umbracoApplication, Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
- : base(umbracoApplication, configs, umbracoVersion, ioHelper, Mock.Of(), Mock.Of(), hostingEnvironment, backOfficeInfo)
+ : base(umbracoApplication, configs, umbracoVersion, ioHelper, Mock.Of(), Mock.Of(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator)
{
}
diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
index 4b06cb7eaf..35fa7e21b7 100644
--- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
+++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs
@@ -122,7 +122,7 @@ namespace Umbraco.Tests.Runtimes
public class TestRuntime : CoreRuntime
{
public TestRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
- :base(configs, umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo)
+ :base(configs, umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator)
{
}
diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
index b0eea91bf4..42484b4650 100644
--- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
+++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
@@ -61,7 +61,7 @@ namespace Umbraco.Tests.Runtimes
var profiler = new LogProfiler(logger);
var profilingLogger = new ProfilingLogger(logger, profiler);
var appCaches = AppCaches.Disabled;
- var databaseFactory = new UmbracoDatabaseFactory(logger, new Lazy(() => factory.GetInstance()), TestHelper.GetConfigs());
+ var databaseFactory = new UmbracoDatabaseFactory(logger, new Lazy(() => factory.GetInstance()), TestHelper.GetConfigs(), TestHelper.DbProviderFactoryCreator);
var typeFinder = new TypeFinder(logger);
var ioHelper = TestHelper.IOHelper;
var hostingEnvironment = Mock.Of();
@@ -75,10 +75,10 @@ namespace Umbraco.Tests.Runtimes
// create the register and the composition
var register = TestHelper.GetRegister();
var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs, ioHelper, appCaches);
- composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion);
+ composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion, TestHelper.DbProviderFactoryCreator);
// create the core runtime and have it compose itself
- var coreRuntime = new CoreRuntime(configs, umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo);coreRuntime.Compose(composition);
+ var coreRuntime = new CoreRuntime(configs, umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator);coreRuntime.Compose(composition);
// determine actual runtime level
runtimeState.DetermineRuntimeLevel(databaseFactory, logger);
@@ -270,10 +270,10 @@ namespace Umbraco.Tests.Runtimes
var register = TestHelper.GetRegister();
var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs, ioHelper, appCaches);
var umbracoVersion = TestHelper.GetUmbracoVersion();
- composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion);
+ composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion, TestHelper.DbProviderFactoryCreator);
// create the core runtime and have it compose itself
- var coreRuntime = new CoreRuntime(configs, umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo);
+ var coreRuntime = new CoreRuntime(configs, umbracoVersion, ioHelper, logger, profiler, new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, TestHelper.DbProviderFactoryCreator);
coreRuntime.Compose(composition);
// get the components
diff --git a/src/Umbraco.Tests/TestHelpers/TestHelper.cs b/src/Umbraco.Tests/TestHelpers/TestHelper.cs
index cc536f0fac..6aefdbb5f6 100644
--- a/src/Umbraco.Tests/TestHelpers/TestHelper.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestHelper.cs
@@ -18,6 +18,7 @@ using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
+using Umbraco.Core.Persistence;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
@@ -84,6 +85,7 @@ namespace Umbraco.Tests.TestHelpers
}
public static IShortStringHelper ShortStringHelper => new DefaultShortStringHelper(new DefaultShortStringHelperConfig());
+ public static IDbProviderFactoryCreator DbProviderFactoryCreator => new UmbracoDbProviderFactoryCreator(Constants.DbProviderNames.SqlCe);
public static IIOHelper IOHelper = new IOHelper(GetHostingEnvironment());
diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects.cs b/src/Umbraco.Tests/TestHelpers/TestObjects.cs
index 21d1cbc20f..71e02c9e5e 100644
--- a/src/Umbraco.Tests/TestHelpers/TestObjects.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestObjects.cs
@@ -243,7 +243,7 @@ namespace Umbraco.Tests.TestHelpers
// mappersBuilder.AddCore();
// var mappers = mappersBuilder.CreateCollection();
var mappers = Current.Factory.GetInstance();
- databaseFactory = new UmbracoDatabaseFactory(Constants.System.UmbracoConnectionName, logger, new Lazy(() => mappers), TestHelper.GetConfigs());
+ databaseFactory = new UmbracoDatabaseFactory(Constants.System.UmbracoConnectionName, logger, new Lazy(() => mappers), TestHelper.GetConfigs(), TestHelper.DbProviderFactoryCreator);
}
typeFinder = typeFinder ?? new TypeFinder(logger);
diff --git a/src/Umbraco.Tests/Testing/TestDatabase.cs b/src/Umbraco.Tests/Testing/TestDatabase.cs
index b1ddbd08d4..f8ec573e06 100644
--- a/src/Umbraco.Tests/Testing/TestDatabase.cs
+++ b/src/Umbraco.Tests/Testing/TestDatabase.cs
@@ -236,6 +236,8 @@ namespace Umbraco.Tests.Testing
throw new NotImplementedException();
}
+ public Task InsertBatchAsync(IEnumerable pocos, BatchOptions options = null) => throw new NotImplementedException();
+
public Task UpdateAsync(object poco)
{
throw new NotImplementedException();
@@ -251,16 +253,24 @@ namespace Umbraco.Tests.Testing
throw new NotImplementedException();
}
+ public Task UpdateBatchAsync(IEnumerable> pocos, BatchOptions options = null) => throw new NotImplementedException();
+
public Task DeleteAsync(object poco)
{
throw new NotImplementedException();
}
+ public IAsyncUpdateQueryProvider UpdateManyAsync() => throw new NotImplementedException();
+
+ public IAsyncDeleteQueryProvider DeleteManyAsync() => throw new NotImplementedException();
+
public void InsertBulk(IEnumerable pocos)
{
throw new NotImplementedException();
}
+ int IDatabase.InsertBatch(IEnumerable pocos, BatchOptions options) => throw new NotImplementedException();
+
public void InsertBatch(IEnumerable pocos, BatchOptions options = null)
{
throw new NotImplementedException();
@@ -321,6 +331,8 @@ namespace Umbraco.Tests.Testing
throw new NotImplementedException();
}
+ public int UpdateBatch(IEnumerable> pocos, BatchOptions options = null) => throw new NotImplementedException();
+
public IUpdateQueryProvider UpdateMany()
{
throw new NotImplementedException();
@@ -700,6 +712,8 @@ namespace Umbraco.Tests.Testing
throw new NotImplementedException();
}
+ public IAsyncQueryProviderWithIncludes QueryAsync() => throw new NotImplementedException();
+
public Task> FetchAsync(string sql, params object[] args)
{
throw new NotImplementedException();
diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
index dbae2514eb..3982077c2e 100644
--- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
+++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
@@ -409,7 +409,8 @@ namespace Umbraco.Tests.Testing
Constants.System.UmbracoConnectionName,
Logger,
new Lazy(f.GetInstance),
- TestHelper.GetConfigs()));
+ TestHelper.GetConfigs(),
+ TestHelper.DbProviderFactoryCreator));
Composition.RegisterUnique(f => f.TryGetInstance().SqlContext);
Composition.WithCollectionBuilder(); // empty
diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj
index df67d46afa..82a2bc5dab 100644
--- a/src/Umbraco.Tests/Umbraco.Tests.csproj
+++ b/src/Umbraco.Tests/Umbraco.Tests.csproj
@@ -100,7 +100,7 @@
-
+
@@ -108,6 +108,7 @@
+
diff --git a/src/Umbraco.Web/Runtime/WebRuntime.cs b/src/Umbraco.Web/Runtime/WebRuntime.cs
index 9a42c19e0a..791cbe87f4 100644
--- a/src/Umbraco.Web/Runtime/WebRuntime.cs
+++ b/src/Umbraco.Web/Runtime/WebRuntime.cs
@@ -6,6 +6,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
+using Umbraco.Core.Persistence;
using Umbraco.Core.Runtime;
using Umbraco.Web.Cache;
using Umbraco.Web.Composing;
@@ -26,8 +27,8 @@ namespace Umbraco.Web.Runtime
/// Initializes a new instance of the class.
///
///
- public WebRuntime(UmbracoApplicationBase umbracoApplication, Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo):
- base(configs, umbracoVersion, ioHelper, logger, profiler ,new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo)
+ public WebRuntime(UmbracoApplicationBase umbracoApplication, Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo, IDbProviderFactoryCreator dbProviderFactoryCreator):
+ base(configs, umbracoVersion, ioHelper, logger, profiler ,new AspNetUmbracoBootPermissionChecker(), hostingEnvironment, backOfficeInfo, dbProviderFactoryCreator)
{
_umbracoApplication = umbracoApplication;
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 231c6b8e2f..73694fbc28 100755
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -87,7 +87,7 @@
-
+
3.3.0
runtime; build; native; contentfiles; analyzers
@@ -288,6 +288,7 @@
+
diff --git a/src/Umbraco.Web/UmbracoApplication.cs b/src/Umbraco.Web/UmbracoApplication.cs
index c93492ee3d..74fdcd8930 100644
--- a/src/Umbraco.Web/UmbracoApplication.cs
+++ b/src/Umbraco.Web/UmbracoApplication.cs
@@ -16,7 +16,7 @@ namespace Umbraco.Web
{
protected override IRuntime GetRuntime(Configs configs, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo)
{
- return new WebRuntime(this, configs, umbracoVersion, ioHelper, logger, profiler, hostingEnvironment, backOfficeInfo);
+ return new WebRuntime(this, configs, umbracoVersion, ioHelper, logger, profiler, hostingEnvironment, backOfficeInfo, new UmbracoDbProviderFactoryCreator(Constants.DbProviderNames.SqlCe));
}
///
diff --git a/src/Umbraco.Web/UmbracoDbProviderFactoryCreator.cs b/src/Umbraco.Web/UmbracoDbProviderFactoryCreator.cs
new file mode 100644
index 0000000000..a07ea3affc
--- /dev/null
+++ b/src/Umbraco.Web/UmbracoDbProviderFactoryCreator.cs
@@ -0,0 +1,27 @@
+using System.Data.Common;
+using Umbraco.Core.Persistence;
+
+namespace Umbraco.Web
+{
+ public class UmbracoDbProviderFactoryCreator : IDbProviderFactoryCreator
+ {
+ private readonly string _defaultProviderName;
+
+ public UmbracoDbProviderFactoryCreator(string defaultProviderName)
+ {
+ _defaultProviderName = defaultProviderName;
+ }
+
+ public DbProviderFactory CreateFactory()
+ {
+ return CreateFactory(_defaultProviderName);
+ }
+
+ public DbProviderFactory CreateFactory(string providerName)
+ {
+ if (string.IsNullOrEmpty(providerName)) return null;
+
+ return DbProviderFactories.GetFactory(providerName);
+ }
+ }
+}