Skip to content

Commit

Permalink
Merge pull request #3 from mullerc/fix-temp-table-name
Browse files Browse the repository at this point in the history
Fix temporary table naming by removing '.' from name
  • Loading branch information
Martin Kostov authored Jun 4, 2018
2 parents ce9b57b + c164f84 commit 1495e2e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Dapper.Bulk/DapperBulk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void BulkInsert<T>(this SqlConnection connection, IEnumerable<T> d

var allPropertiesExceptKeyAndComputed = allProperties.Except(keyProperties.Union(computedProperties)).ToList();
var allPropertiesExceptKeyAndComputedString = GetColumnsStringSqlServer(allPropertiesExceptKeyAndComputed);
var tempToBeInserted = $"#{tableName}_TempInsert";
var tempToBeInserted = $"#{tableName}_TempInsert".Replace(".", string.Empty);

connection.Execute($@"SELECT TOP 0 {allPropertiesExceptKeyAndComputedString} INTO {tempToBeInserted} FROM {tableName} target WITH(NOLOCK);", null, transaction);

Expand Down Expand Up @@ -82,8 +82,8 @@ public static IEnumerable<T> BulkInsertAndSelect<T>(this SqlConnection connectio
var allPropertiesExceptKeyAndComputedString = GetColumnsStringSqlServer(allPropertiesExceptKeyAndComputed);
var allPropertiesString = GetColumnsStringSqlServer(allProperties, "target.");

var tempToBeInserted = $"#{tableName}_TempInsert";
var tempInsertedWithIdentity = $"@{tableName}_TempInserted";
var tempToBeInserted = $"#{tableName}_TempInsert".Replace(".", string.Empty);
var tempInsertedWithIdentity = $"@{tableName}_TempInserted".Replace(".", string.Empty);

connection.Execute($"SELECT TOP 0 {allPropertiesExceptKeyAndComputedString} INTO {tempToBeInserted} FROM {tableName} target WITH(NOLOCK);", null, transaction);

Expand Down Expand Up @@ -127,7 +127,7 @@ public static async Task BulkInsertAsync<T>(this SqlConnection connection, IEnum
var computedProperties = PropertiesCache.ComputedPropertiesCache(type);
var allPropertiesExceptKeyAndComputed = allProperties.Except(keyProperties.Union(computedProperties)).ToList();
var allPropertiesExceptKeyAndComputedString = GetColumnsStringSqlServer(allPropertiesExceptKeyAndComputed);
var tempToBeInserted = $"#{tableName}_TempInsert";
var tempToBeInserted = $"#{tableName}_TempInsert".Replace(".", string.Empty);

await connection.ExecuteAsync($@"SELECT TOP 0 {allPropertiesExceptKeyAndComputedString} INTO {tempToBeInserted} FROM {tableName} target WITH(NOLOCK);", null, transaction);

Expand Down Expand Up @@ -177,8 +177,8 @@ public static async Task<IEnumerable<T>> BulkInsertAndSelectAsync<T>(this SqlCon
var allPropertiesExceptKeyAndComputedString = GetColumnsStringSqlServer(allPropertiesExceptKeyAndComputed);
var allPropertiesString = GetColumnsStringSqlServer(allProperties, "target.");

var tempToBeInserted = $"#{tableName}_TempInsert";
var tempInsertedWithIdentity = $"@{tableName}_TempInserted";
var tempToBeInserted = $"#{tableName}_TempInsert".Replace(".", string.Empty);
var tempInsertedWithIdentity = $"@{tableName}_TempInserted".Replace(".", string.Empty);

await connection.ExecuteAsync($@"SELECT TOP 0 {allPropertiesExceptKeyAndComputedString} INTO {tempToBeInserted} FROM {tableName} target WITH(NOLOCK);", null, transaction);

Expand Down

0 comments on commit 1495e2e

Please sign in to comment.