Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ FOR JSON PATH

//Dynamically convert to a Lookup for immutable cache of data.
//NOTE: Lookup is immutable (vs Dictionary which is not) and performance for lookups is just as fast.
var tableDefinitionsLookup = tableDefinitionsList.Where(t => t != null).ToLookup(t => t.TableName.ToLowerInvariant());
var tableDefinitionsLookup = tableDefinitionsList.Where(t => t != null).ToLookup(t => t.TableFullyQualifiedName.ToLowerInvariant());
return tableDefinitionsLookup;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public SqlBulkHelpersTableDefinition(String tableSchema, String tableName, List<
}
public String TableSchema { get; private set; }
public String TableName { get; private set; }
public String TableFullyQualifiedName => $"[{TableSchema}].[{TableName}]";
public IList<SqlBulkHelpersColumnDefinition> Columns { get; private set; }
public SqlBulkHelpersColumnDefinition IdentityColumn { get; private set; }

Expand All @@ -44,7 +45,7 @@ public SqlBulkHelpersColumnDefinition FindColumnCaseInsensitive(String columnNam

public override string ToString()
{
return this.TableName;
return this.TableFullyQualifiedName;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SELECT TOP(0)
{columnNamesWithoutIdentityCSV},
-1 as [{SqlBulkHelpersConstants.ROWNUMBER_COLUMN_NAME}]
INTO [{tempStagingTableName}]
FROM [{tableDefinition.TableName}];
FROM [{tableDefinition.TableFullyQualifiedName}];

ALTER TABLE [{tempStagingTableName}] ADD PRIMARY KEY ([{identityColumnName}]);

Expand Down Expand Up @@ -62,7 +62,7 @@ WHEN MATCHED THEN
// In general it results in inverting the order of data being sent in Bulk which then resulted in Identity
// values being incorrect based on the order of data specified.
String sqlScriptToExecuteMergeProcess = $@"
MERGE [{tableDefinition.TableName}] as target
MERGE [{tableDefinition.TableFullyQualifiedName}] as target
USING (
SELECT TOP 100 PERCENT *
FROM [{tempStagingTableName}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ FOR JSON PATH
//Dynamically convert to a Lookup for immutable cache of data.
//NOTE: Lookup is immutable (vs Dictionary which is not) and performance for lookups is just as fast.
var tableDefinitionsLookup = tableDefinitionsList.Where(t => t != null).ToLookup(
t => $"[{t.TableSchema.ToLowerInvariant()}].[{t.TableName.ToLowerInvariant()}]"
t => $"{t.TableFullyQualifiedName.ToLowerInvariant()}"
);
return tableDefinitionsLookup;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public SqlBulkHelpersTableDefinition(String tableSchema, String tableName, List<
}
public String TableSchema { get; private set; }
public String TableName { get; private set; }
public String TableFullyQualifiedName => $"[{TableSchema}].[{TableName}]";
public IList<SqlBulkHelpersColumnDefinition> Columns { get; private set; }
public SqlBulkHelpersColumnDefinition IdentityColumn { get; private set; }

Expand All @@ -44,7 +45,7 @@ public SqlBulkHelpersColumnDefinition FindColumnCaseInsensitive(String columnNam

public override string ToString()
{
return this.TableName;
return this.TableFullyQualifiedName;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SELECT TOP(0)
{columnNamesWithoutIdentityCSV},
-1 as [{SqlBulkHelpersConstants.ROWNUMBER_COLUMN_NAME}]
INTO [{tempStagingTableName}]
FROM [{tableDefinition.TableName}];
FROM {tableDefinition.TableFullyQualifiedName};

ALTER TABLE [{tempStagingTableName}] ADD PRIMARY KEY ([{identityColumnName}]);

Expand Down Expand Up @@ -76,7 +76,7 @@ WHEN MATCHED THEN
// custom match Qualifiers; this ensures that data is sorted in a way that postprocessing
// can occur & be validated as expected.
String sqlScriptToExecuteMergeProcess = $@"
MERGE [{tableDefinition.TableName}] as target
MERGE {tableDefinition.TableFullyQualifiedName} as target
USING (
SELECT TOP 100 PERCENT *
FROM [{tempStagingTableName}]
Expand Down