Skip to content

Commit

Permalink
Merge pull request #53 from dynamicweb/mss/21058-MappingExtensions-Au…
Browse files Browse the repository at this point in the history
…toID

Removed local ReplaceKeyColumnsWithAutoIdIfExists and replaced call t…
  • Loading branch information
frederik5480 authored Oct 3, 2024
2 parents ebf3e4a + a805ae1 commit ee71011
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.7.0</Version>
<Version>10.8.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Dynamicweb Provider</Title>
<Description>Dynamicweb Provider</Description>
Expand All @@ -23,8 +23,8 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.7.0" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.7.0" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.8.0" />
<PackageReference Include="Dynamicweb.Ecommerce" Version="10.8.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
</Project>
20 changes: 1 addition & 19 deletions src/DynamicwebProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,24 +437,6 @@ public override void OverwriteDestinationSchemaToOriginal()
Schema = GetOriginalSourceSchema();
}

private static IEnumerable<ColumnMapping> 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;
}

public override bool RunJob(Job job)
{
if (IsFirstJobRun)
Expand All @@ -475,7 +457,7 @@ public override bool RunJob(Job job)
{
if (mapping.Active)
{
var columnMappings = ReplaceKeyColumnsWithAutoIdIfExists(mapping);
var columnMappings = MappingExtensions.ReplaceKeyColumnsWithAutoIdIfExists(mapping);
Logger.Log("Starting import to temporary table for " + mapping.DestinationTable.Name + ".");
using (var reader = job.Source.GetReader(mapping))
{
Expand Down

0 comments on commit ee71011

Please sign in to comment.