Skip to content

Commit

Permalink
data merge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Dec 5, 2022
1 parent 9c213af commit 6aa819b
Show file tree
Hide file tree
Showing 34 changed files with 74 additions and 228 deletions.
3 changes: 1 addition & 2 deletions src/FluentCommand.SqlServer/Bulk/DataBulkCopyMapping.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Linq.Expressions;
using System.Reflection;

Expand Down Expand Up @@ -110,4 +109,4 @@ private string ExtractColumnName<TValue>(Expression<Func<TEntity, TValue>> sourc

return property.Name;
}
}
}
2 changes: 0 additions & 2 deletions src/FluentCommand.SqlServer/Bulk/IDataBulkCopy.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using System.Data;

using Microsoft.Data.SqlClient;
Expand Down
7 changes: 2 additions & 5 deletions src/FluentCommand.SqlServer/Import/FieldDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;

namespace FluentCommand.Import;

/// <summary>
Expand Down Expand Up @@ -120,11 +117,11 @@ public FieldDefinition()
/// Converts to string.
/// </summary>
/// <returns>
/// A <see cref="System.String" /> that represents this instance.
/// A <see cref="string" /> that represents this instance.
/// </returns>
public override string ToString()
{
return $"Display: {DisplayName}, Name: {Name}, DataType: {DataType?.Name}";
}

}
}
7 changes: 2 additions & 5 deletions src/FluentCommand.SqlServer/Import/FieldDefinitionBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;

namespace FluentCommand.Import;

/// <summary>
Expand Down Expand Up @@ -217,11 +214,11 @@ public FieldDefinitionBuilder Expressions(IEnumerable<string> values)
/// <returns>
/// Fluent builder for <see cref="FieldDefinition" />
/// </returns>
public FieldDefinitionBuilder Translator<T>()
public FieldDefinitionBuilder Translator<T>()
where T : IFieldTranslator
{
_fieldDefinition.Translator = typeof(T);
return this;
}

}
}
4 changes: 1 addition & 3 deletions src/FluentCommand.SqlServer/Import/IFieldTranslator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Threading.Tasks;

namespace FluentCommand.Import;

/// <summary>
Expand All @@ -13,4 +11,4 @@ public interface IFieldTranslator
/// <param name="original">The original value.</param>
/// <returns>The translated value</returns>
Task<object> Translate(string original);
}
}
7 changes: 1 addition & 6 deletions src/FluentCommand.SqlServer/Import/IImportProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using System;
using System.Data;
using System.Threading;
using System.Threading.Tasks;

namespace FluentCommand.Import;

/// <summary>
Expand All @@ -20,4 +15,4 @@ public interface IImportProcessor
/// <returns>The results of the import</returns>
/// <exception cref="ArgumentNullException"><paramref name="importData" /> or <paramref name="importDefinition" /> is null</exception>
Task<ImportResult> ImportAsync(ImportDefinition importDefinition, ImportData importData, string username, CancellationToken cancellationToken = default);
}
}
3 changes: 1 addition & 2 deletions src/FluentCommand.SqlServer/Import/IImportValidator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Data;
using System.Threading.Tasks;
using System.Data;

namespace FluentCommand.Import;

Expand Down
4 changes: 1 addition & 3 deletions src/FluentCommand.SqlServer/Import/ImportData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections.Generic;

namespace FluentCommand.Import;

/// <summary>
Expand Down Expand Up @@ -38,4 +36,4 @@ public class ImportData
/// <c>true</c> if data has a header row; otherwise, <c>false</c>.
/// </value>
public bool HasHeader { get; set; } = true;
}
}
7 changes: 2 additions & 5 deletions src/FluentCommand.SqlServer/Import/ImportDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;

namespace FluentCommand.Import;

/// <summary>
Expand All @@ -25,7 +22,7 @@ public ImportDefinition()
/// The name of the import.
/// </value>
public string Name { get; set; }

/// <summary>
/// Gets or sets the target table to merge the uploaded data into.
/// </summary>
Expand Down Expand Up @@ -93,4 +90,4 @@ public static ImportDefinition Build(Action<ImportDefinitionBuilder> builder)
return importDefinition;
}

}
}
10 changes: 2 additions & 8 deletions src/FluentCommand.SqlServer/Import/ImportDefinitionBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Linq;

namespace FluentCommand.Import;

/// <summary>
Expand All @@ -17,10 +14,7 @@ public class ImportDefinitionBuilder
/// <exception cref="ArgumentNullException">importDefinition</exception>
public ImportDefinitionBuilder(ImportDefinition importDefinition)
{
if (importDefinition == null)
throw new ArgumentNullException(nameof(importDefinition));

_importDefinition = importDefinition;
_importDefinition = importDefinition ?? throw new ArgumentNullException(nameof(importDefinition));
}


Expand Down Expand Up @@ -174,4 +168,4 @@ public ImportDefinitionBuilder Validator<T>()
_importDefinition.Validator = typeof(T);
return this;
}
}
}
4 changes: 0 additions & 4 deletions src/FluentCommand.SqlServer/Import/ImportFactory.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace FluentCommand.Import;

/// <summary>
Expand Down
9 changes: 2 additions & 7 deletions src/FluentCommand.SqlServer/Import/ImportFieldMapping.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace FluentCommand.Import;

/// <summary>
Expand All @@ -23,10 +21,7 @@ public ImportFieldMapping(FieldDefinition fieldDefinition) : this(fieldDefinitio
/// <exception cref="ArgumentNullException">definition is null</exception>
public ImportFieldMapping(FieldDefinition fieldDefinition, FieldMap fieldMap)
{
if (fieldDefinition == null)
throw new ArgumentNullException(nameof(fieldDefinition));

Definition = fieldDefinition;
Definition = fieldDefinition ?? throw new ArgumentNullException(nameof(fieldDefinition));
FieldMap = fieldMap;
}

Expand All @@ -45,4 +40,4 @@ public ImportFieldMapping(FieldDefinition fieldDefinition, FieldMap fieldMap)
/// The field mapping.
/// </value>
public FieldMap FieldMap { get; }
}
}
6 changes: 1 addition & 5 deletions src/FluentCommand.SqlServer/Import/ImportProcessContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace FluentCommand.Import;

/// <summary>
Expand Down Expand Up @@ -128,4 +124,4 @@ private List<ImportFieldMapping> GetMappedFields()

return list;
}
}
}
6 changes: 0 additions & 6 deletions src/FluentCommand.SqlServer/Import/ImportProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using FluentCommand.Extensions;
using FluentCommand.Merge;
Expand Down
5 changes: 1 addition & 4 deletions src/FluentCommand.SqlServer/Import/ImportResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;

namespace FluentCommand.Import;

/// <summary>
Expand Down Expand Up @@ -31,4 +28,4 @@ public class ImportResult
/// The list of errors.
/// </value>
public IReadOnlyCollection<Exception> Errors { get; set; }
}
}
7 changes: 1 addition & 6 deletions src/FluentCommand.SqlServer/Merge/DataMerge.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using FluentCommand.Extensions;

Expand Down Expand Up @@ -555,7 +550,7 @@ await executeFactory(mergeCommand, cancellationToken)
}
finally
{
_dataSession.ReleaseConnection();
await _dataSession.ReleaseConnectionAsync();
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/FluentCommand.SqlServer/Merge/DataMergeColumn.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace FluentCommand.Merge;

/// <summary>
Expand Down Expand Up @@ -80,4 +78,4 @@ public DataMergeColumn()
/// <c>true</c> if the column is ignored; otherwise, <c>false</c>.
/// </value>
public bool IsIgnored { get; set; }
}
}
4 changes: 1 addition & 3 deletions src/FluentCommand.SqlServer/Merge/DataMergeColumnMapping.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace FluentCommand.Merge;

/// <summary>
Expand Down Expand Up @@ -118,4 +116,4 @@ public IDataColumnMapping Ignore(bool value = true)
MergeColumn.IsIgnored = value;
return this;
}
}
}
5 changes: 1 addition & 4 deletions src/FluentCommand.SqlServer/Merge/DataMergeDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;

using FluentCommand.Extensions;

Expand Down Expand Up @@ -122,7 +119,7 @@ public static void AutoMap<TEntity>(DataMergeDefinition mergeDefinition)
var entityType = typeof(TEntity);
var properties = TypeDescriptor.GetProperties(entityType);


var tableAttribute = Attribute.GetCustomAttribute(entityType, typeof(TableAttribute)) as TableAttribute;
if (tableAttribute != null)
{
Expand Down
2 changes: 0 additions & 2 deletions src/FluentCommand.SqlServer/Merge/DataMergeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace FluentCommand.Merge;

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions src/FluentCommand.SqlServer/Merge/DataMergeGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

using FluentCommand.Extensions;
Expand Down
3 changes: 1 addition & 2 deletions src/FluentCommand.SqlServer/Merge/DataMergeMapping.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Linq.Expressions;
using System.Reflection;

Expand Down Expand Up @@ -112,4 +111,4 @@ public IDataColumnMapping Column(string sourceColumn)

return columnMapping;
}
}
}
4 changes: 2 additions & 2 deletions src/FluentCommand.SqlServer/Merge/DataMergeMode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FluentCommand.Merge;
namespace FluentCommand.Merge;

/// <summary>
/// How the data should be merged into the table
Expand All @@ -17,4 +17,4 @@ public enum DataMergeMode
/// Generate a SqlServer merge statement to execute.
/// </summary>
SqlStatement
}
}
8 changes: 3 additions & 5 deletions src/FluentCommand.SqlServer/Merge/DataMergeOutputColumn.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace FluentCommand.Merge;

/// <summary>
Expand All @@ -14,15 +12,15 @@ public class DataMergeOutputColumn
/// The name of the column.
/// </value>
public string Name { get; set; }

/// <summary>
/// Gets or sets the current value of the column.
/// </summary>
/// <value>
/// The current value of the column.
/// </value>
public object Current { get; set; }

/// <summary>
/// Gets or sets the original value of the column.
/// </summary>
Expand All @@ -38,4 +36,4 @@ public class DataMergeOutputColumn
/// The column value type.
/// </value>
public Type Type { get; set; }
}
}
6 changes: 1 addition & 5 deletions src/FluentCommand.SqlServer/Merge/DataMergeOutputRow.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace FluentCommand.Merge;

/// <summary>
Expand Down Expand Up @@ -48,4 +44,4 @@ public DataMergeOutputRow()
return Columns.FirstOrDefault(c => c.Name == columnName);
}
}
}
}

0 comments on commit 6aa819b

Please sign in to comment.