Merge remote-tracking branch 'origin/netcore/feature/move-files' into netcore/feature/AB3791-Move-scoping-to-infrastructure-and-replace-callcontext
This commit is contained in:
@@ -4,6 +4,6 @@ namespace Umbraco.Core.Persistence
|
||||
{
|
||||
public interface IBulkSqlInsertProvider
|
||||
{
|
||||
int BulkInsertRecords<T>(IUmbracoDatabase database, IEnumerable<T> records, bool useNativeBulkInsert);
|
||||
int BulkInsertRecords<T>(IUmbracoDatabase database, IEnumerable<T> records);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@ namespace Umbraco.Core.Persistence
|
||||
|
||||
bool EnableSqlCount { get; set; }
|
||||
int SqlCount { get; }
|
||||
int BulkInsertRecords<T>(IEnumerable<T> records, bool useNativeBulkInsert = true);
|
||||
int BulkInsertRecords<T>(IEnumerable<T> records);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,26 +30,6 @@ namespace Umbraco.Core.Persistence
|
||||
SqlBulkCopyHelper.SqlTransactionResolver = dbTran => GetTypedTransaction<SqlTransaction>(dbTran);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulk-inserts records within a transaction.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the records.</typeparam>
|
||||
/// <param name="database">The database.</param>
|
||||
/// <param name="records">The records.</param>
|
||||
/// <param name="useNativeBulkInsert">Whether to use native bulk insert when available.</param>
|
||||
public static void BulkInsertRecordsWithTransaction<T>(this IUmbracoDatabase database, IEnumerable<T> records, bool useNativeBulkInsert = true)
|
||||
{
|
||||
var recordsA = records.ToArray();
|
||||
if (recordsA.Length == 0)
|
||||
return;
|
||||
|
||||
// no need to "try...catch", if the transaction is not completed it will rollback!
|
||||
using (var tr = database.GetTransaction())
|
||||
{
|
||||
database.BulkInsertRecords(recordsA, useNativeBulkInsert);
|
||||
tr.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates bulk-insert commands.
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Persistence
|
||||
{
|
||||
public class SqlServerBulkSqlInsertProvider : IBulkSqlInsertProvider
|
||||
{
|
||||
public int BulkInsertRecords<T>(IUmbracoDatabase database, IEnumerable<T> records, bool useNativeBulkInsert)
|
||||
public int BulkInsertRecords<T>(IUmbracoDatabase database, IEnumerable<T> records)
|
||||
{
|
||||
var recordsA = records.ToArray();
|
||||
if (recordsA.Length == 0) return 0;
|
||||
@@ -18,10 +18,9 @@ namespace Umbraco.Core.Persistence
|
||||
var pocoData = database.PocoDataFactory.ForType(typeof(T));
|
||||
if (pocoData == null) throw new InvalidOperationException("Could not find PocoData for " + typeof(T));
|
||||
|
||||
return useNativeBulkInsert && database.DatabaseType.IsSqlServer2008OrLater()
|
||||
return database.DatabaseType.IsSqlServer2008OrLater()
|
||||
? BulkInsertRecordsSqlServer(database, pocoData, recordsA)
|
||||
: BulkInsertRecordsWithCommands(database, recordsA);
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -162,9 +162,9 @@ namespace Umbraco.Core.Persistence
|
||||
/// </summary>
|
||||
public int SqlCount { get; private set; }
|
||||
|
||||
public int BulkInsertRecords<T>(IEnumerable<T> records, bool useNativeBulkInsert = true)
|
||||
public int BulkInsertRecords<T>(IEnumerable<T> records)
|
||||
{
|
||||
return _bulkSqlInsertProvider.BulkInsertRecords(this, records, useNativeBulkInsert);
|
||||
return _bulkSqlInsertProvider.BulkInsertRecords(this, records);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
<_UnmanagedRegistrationCache Remove="obj\Umbraco.Infrastructure.csproj.UnmanagedRegistration.cache" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="obj\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Remove="obj\**" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user