From e3ecb37f52a115485fc99c22bdbbdba1e2851681 Mon Sep 17 00:00:00 2001 From: Matthias Sebastian Sort Date: Wed, 2 Oct 2024 11:27:31 +0200 Subject: [PATCH] Removed local ReplaceKeyColumnsWithAutoIdIfExists and replaced call to MappingExtensions.ReplaceKeyColumnsWithAutoIdIfExists --- ...taIntegration.Providers.SqlProvider.csproj | 4 ++-- src/SQLDestinationWriter.cs | 24 +++---------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/Dynamicweb.DataIntegration.Providers.SqlProvider.csproj b/src/Dynamicweb.DataIntegration.Providers.SqlProvider.csproj index 988b8bc..471260d 100644 --- a/src/Dynamicweb.DataIntegration.Providers.SqlProvider.csproj +++ b/src/Dynamicweb.DataIntegration.Providers.SqlProvider.csproj @@ -1,6 +1,6 @@  - 10.7.0 + 10.8.0 1.0.0.0 SQL Provider SQL Provider @@ -23,7 +23,7 @@ snupkg - + diff --git a/src/SQLDestinationWriter.cs b/src/SQLDestinationWriter.cs index d83c7df..05e095d 100644 --- a/src/SQLDestinationWriter.cs +++ b/src/SQLDestinationWriter.cs @@ -91,7 +91,7 @@ public SqlDestinationWriter(Mapping mapping, SqlConnection connection, bool remo public SqlDestinationWriter(Mapping mapping, SqlConnection connection, bool removeMissingAfterImport, ILogger logger, string tempTablePrefix, bool discardDuplicates) { Mapping = mapping; - _columnMappings = new ColumnMappingCollection(ReplaceKeyColumnsWithAutoIdIfExists(Mapping)); + _columnMappings = new ColumnMappingCollection(MappingExtensions.ReplaceKeyColumnsWithAutoIdIfExists(Mapping)); SqlCommand = connection.CreateCommand(); SqlCommand.CommandTimeout = 1200; this.removeMissingAfterImport = removeMissingAfterImport; @@ -118,7 +118,7 @@ public SqlDestinationWriter(Mapping mapping, SqlConnection connection, bool remo public SqlDestinationWriter(Mapping mapping, SqlConnection connection, bool removeMissingAfterImport, ILogger logger, bool discardDuplicates) { Mapping = mapping; - _columnMappings = new ColumnMappingCollection(ReplaceKeyColumnsWithAutoIdIfExists(Mapping)); + _columnMappings = new ColumnMappingCollection(MappingExtensions.ReplaceKeyColumnsWithAutoIdIfExists(Mapping)); SqlCommand = connection.CreateCommand(); SqlCommand.CommandTimeout = 1200; this.removeMissingAfterImport = removeMissingAfterImport; @@ -145,7 +145,7 @@ public SqlDestinationWriter(Mapping mapping, SqlConnection connection, bool remo public SqlDestinationWriter(Mapping mapping, SqlCommand mockSqlCommand, bool removeMissingAfterImport, ILogger logger, string tempTablePrefix, bool discardDuplicates) { Mapping = mapping; - _columnMappings = new ColumnMappingCollection(ReplaceKeyColumnsWithAutoIdIfExists(Mapping)); + _columnMappings = new ColumnMappingCollection(MappingExtensions.ReplaceKeyColumnsWithAutoIdIfExists(Mapping)); SqlCommand = mockSqlCommand; this.removeMissingAfterImport = removeMissingAfterImport; this.logger = logger; @@ -179,24 +179,6 @@ public SqlDestinationWriter(Mapping mapping, SqlCommand mockSqlCommand, bool rem } } - private static IEnumerable ReplaceKeyColumnsWithAutoIdIfExists(Mapping mapping) - { - //will move this to MappingExtensions - US https://dev.azure.com/dynamicwebsoftware/Dynamicweb/_workitems/edit/20900 - if (mapping == null) return []; - - var autoIdDestinationColumnName = MappingExtensions.GetAutoIdColumnName(mapping.DestinationTable?.Name ?? ""); - if (string.IsNullOrEmpty(autoIdDestinationColumnName)) return mapping.GetColumnMappings(); - - var columnMappings = mapping.GetColumnMappings().ToList(); - var autoIdColumnMapping = columnMappings.Where(obj => obj.DestinationColumn.Name.Equals(autoIdDestinationColumnName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); - if (autoIdColumnMapping != null) - { - columnMappings.ForEach(obj => obj.IsKey = false); - autoIdColumnMapping.IsKey = true; - } - return columnMappings; - } - /// /// Writes the specified row. ///