using System.Collections.Generic; using System.Linq; namespace Umbraco.Core.Persistence { /// /// A provider that just generates insert commands /// public class BasicBulkSqlInsertProvider : IBulkSqlInsertProvider { public string ProviderName => Constants.DatabaseProviders.SqlServer; public int BulkInsertRecords(IUmbracoDatabase database, IEnumerable records) { var recordsA = records.ToArray(); if (recordsA.Length == 0) return 0; return BulkInsertRecordsWithCommands(database, recordsA); } /// /// Bulk-insert records using commands. /// /// The type of the records. /// The database. /// The records. /// The number of records that were inserted. internal static int BulkInsertRecordsWithCommands(IUmbracoDatabase database, T[] records) { foreach (var command in database.GenerateBulkInsertCommands(records)) command.ExecuteNonQuery(); return records.Length; // what else? } } }