Skip to content

Commit bfc9f51

Browse files
committed
ConnectionContextExtensions
1 parent 8c5702a commit bfc9f51

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

src/EntityFrameworkCore.SqlServer.SimpleBulks/BulkDelete/BulkDeleteBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public BulkDeleteResult Execute(IEnumerable<T> data)
9393

9494
Log($"Begin executing SqlBulkCopy. TableName: {temptableName}");
9595

96-
dataTable.SqlBulkCopy(temptableName, null, _connectionContext, _options);
96+
_connectionContext.SqlBulkCopy(dataTable, temptableName, null, _options);
9797

9898
Log("End executing SqlBulkCopy.");
9999

@@ -176,7 +176,7 @@ public async Task<BulkDeleteResult> ExecuteAsync(IEnumerable<T> data, Cancellati
176176

177177
Log($"Begin executing SqlBulkCopy. TableName: {temptableName}");
178178

179-
await dataTable.SqlBulkCopyAsync(temptableName, null, _connectionContext, _options, cancellationToken);
179+
await _connectionContext.SqlBulkCopyAsync(dataTable, temptableName, null, _options, cancellationToken);
180180

181181
Log("End executing SqlBulkCopy.");
182182

src/EntityFrameworkCore.SqlServer.SimpleBulks/BulkInsert/BulkInsertBuilder.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void Execute(IEnumerable<T> data)
121121
_connectionContext.EnsureOpen();
122122

123123
Log($"Begin executing SqlBulkCopy. TableName: {_table.SchemaQualifiedTableName}");
124-
dataTable.SqlBulkCopy(_table.SchemaQualifiedTableName, _table.ColumnNameMappings, _connectionContext, _options);
124+
_connectionContext.SqlBulkCopy(dataTable, _table.SchemaQualifiedTableName, _table.ColumnNameMappings, _options);
125125
Log("End executing SqlBulkCopy.");
126126
return;
127127
}
@@ -139,7 +139,7 @@ public void Execute(IEnumerable<T> data)
139139
_connectionContext.EnsureOpen();
140140

141141
Log($"Begin executing SqlBulkCopy. TableName: {_table.SchemaQualifiedTableName}");
142-
dataTable.SqlBulkCopy(_table.SchemaQualifiedTableName, _table.ColumnNameMappings, _connectionContext, _options);
142+
_connectionContext.SqlBulkCopy(dataTable, _table.SchemaQualifiedTableName, _table.ColumnNameMappings, _options);
143143
Log("End executing SqlBulkCopy.");
144144
return;
145145
}
@@ -166,7 +166,7 @@ public void Execute(IEnumerable<T> data)
166166
_connectionContext.EnsureOpen();
167167

168168
Log($"Begin executing SqlBulkCopy. TableName: {_table.SchemaQualifiedTableName}");
169-
dataTable.SqlBulkCopy(_table.SchemaQualifiedTableName, _table.ColumnNameMappings, _connectionContext, _options);
169+
_connectionContext.SqlBulkCopy(dataTable, _table.SchemaQualifiedTableName, _table.ColumnNameMappings, _options);
170170
Log("End executing SqlBulkCopy.");
171171
return;
172172
}
@@ -198,7 +198,7 @@ public void Execute(IEnumerable<T> data)
198198
Log("End creating temp table.");
199199

200200
Log($"Begin executing SqlBulkCopy. TableName: {temptableName}");
201-
dataTable.SqlBulkCopy(temptableName, null, _connectionContext, _options);
201+
_connectionContext.SqlBulkCopy(dataTable, temptableName, null, _options);
202202
Log("End executing SqlBulkCopy.");
203203

204204
var returnedIds = new Dictionary<long, object>();
@@ -320,7 +320,7 @@ public async Task ExecuteAsync(IEnumerable<T> data, CancellationToken cancellati
320320
await _connectionContext.EnsureOpenAsync(cancellationToken);
321321

322322
Log($"Begin executing SqlBulkCopy. TableName: {_table.SchemaQualifiedTableName}");
323-
await dataTable.SqlBulkCopyAsync(_table.SchemaQualifiedTableName, _table.ColumnNameMappings, _connectionContext, _options, cancellationToken);
323+
await _connectionContext.SqlBulkCopyAsync(dataTable, _table.SchemaQualifiedTableName, _table.ColumnNameMappings, _options, cancellationToken);
324324
Log("End executing SqlBulkCopy.");
325325
return;
326326
}
@@ -338,7 +338,7 @@ public async Task ExecuteAsync(IEnumerable<T> data, CancellationToken cancellati
338338
await _connectionContext.EnsureOpenAsync(cancellationToken);
339339

340340
Log($"Begin executing SqlBulkCopy. TableName: {_table.SchemaQualifiedTableName}");
341-
await dataTable.SqlBulkCopyAsync(_table.SchemaQualifiedTableName, _table.ColumnNameMappings, _connectionContext, _options, cancellationToken);
341+
await _connectionContext.SqlBulkCopyAsync(dataTable, _table.SchemaQualifiedTableName, _table.ColumnNameMappings, _options, cancellationToken);
342342
Log("End executing SqlBulkCopy.");
343343
return;
344344
}
@@ -365,7 +365,7 @@ public async Task ExecuteAsync(IEnumerable<T> data, CancellationToken cancellati
365365
await _connectionContext.EnsureOpenAsync(cancellationToken);
366366

367367
Log($"Begin executing SqlBulkCopy. TableName: {_table.SchemaQualifiedTableName}");
368-
await dataTable.SqlBulkCopyAsync(_table.SchemaQualifiedTableName, _table.ColumnNameMappings, _connectionContext, _options, cancellationToken);
368+
await _connectionContext.SqlBulkCopyAsync(dataTable, _table.SchemaQualifiedTableName, _table.ColumnNameMappings, _options, cancellationToken);
369369
Log("End executing SqlBulkCopy.");
370370
return;
371371
}
@@ -397,7 +397,7 @@ public async Task ExecuteAsync(IEnumerable<T> data, CancellationToken cancellati
397397
Log("End creating temp table.");
398398

399399
Log($"Begin executing SqlBulkCopy. TableName: {temptableName}");
400-
await dataTable.SqlBulkCopyAsync(temptableName, null, _connectionContext, _options, cancellationToken);
400+
await _connectionContext.SqlBulkCopyAsync(dataTable, temptableName, null, _options, cancellationToken);
401401
Log("End executing SqlBulkCopy.");
402402

403403
var returnedIds = new Dictionary<long, object>();

src/EntityFrameworkCore.SqlServer.SimpleBulks/BulkMatch/BulkMatchBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public List<T> Execute(IEnumerable<T> machedValues)
115115

116116
Log($"Begin executing SqlBulkCopy. TableName: {temptableName}");
117117

118-
dataTable.SqlBulkCopy(temptableName, null, _connectionContext, _options);
118+
_connectionContext.SqlBulkCopy(dataTable, temptableName, null, _options);
119119

120120
Log("End executing SqlBulkCopy.");
121121

@@ -190,7 +190,7 @@ public async Task<List<T>> ExecuteAsync(IEnumerable<T> machedValues, Cancellatio
190190

191191
Log($"Begin executing SqlBulkCopy. TableName: {temptableName}");
192192

193-
await dataTable.SqlBulkCopyAsync(temptableName, null, _connectionContext, _options, cancellationToken);
193+
await _connectionContext.SqlBulkCopyAsync(dataTable, temptableName, null, _options, cancellationToken);
194194

195195
Log("End executing SqlBulkCopy.");
196196

src/EntityFrameworkCore.SqlServer.SimpleBulks/BulkMerge/BulkMergeBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public BulkMergeResult Execute(IEnumerable<T> data)
173173
Log("End creating temp table.");
174174

175175
Log($"Begin executing SqlBulkCopy. TableName: {temptableName}");
176-
dataTable.SqlBulkCopy(temptableName, null, _connectionContext, _options);
176+
_connectionContext.SqlBulkCopy(dataTable, temptableName, null, _options);
177177
Log("End executing SqlBulkCopy.");
178178

179179
var sqlMergeStatement = mergeStatementBuilder.ToString();
@@ -443,7 +443,7 @@ public async Task<BulkMergeResult> ExecuteAsync(IEnumerable<T> data, Cancellatio
443443
Log("End creating temp table.");
444444

445445
Log($"Begin executing SqlBulkCopy. TableName: {temptableName}");
446-
await dataTable.SqlBulkCopyAsync(temptableName, null, _connectionContext, _options, cancellationToken);
446+
await _connectionContext.SqlBulkCopyAsync(dataTable, temptableName, null, _options, cancellationToken);
447447
Log("End executing SqlBulkCopy.");
448448

449449
var sqlMergeStatement = mergeStatementBuilder.ToString();

src/EntityFrameworkCore.SqlServer.SimpleBulks/BulkUpdate/BulkUpdateBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public BulkUpdateResult Execute(IEnumerable<T> data)
111111
Log("End creating temp table.");
112112

113113
Log($"Begin executing SqlBulkCopy. TableName: {temptableName}");
114-
dataTable.SqlBulkCopy(temptableName, null, _connectionContext, _options);
114+
_connectionContext.SqlBulkCopy(dataTable, temptableName, null, _options);
115115
Log("End executing SqlBulkCopy.");
116116

117117
var sqlUpdateStatement = updateStatementBuilder.ToString();
@@ -236,7 +236,7 @@ public async Task<BulkUpdateResult> ExecuteAsync(IEnumerable<T> data, Cancellati
236236
Log("End creating temp table.");
237237

238238
Log($"Begin executing SqlBulkCopy. TableName: {temptableName}");
239-
await dataTable.SqlBulkCopyAsync(temptableName, null, _connectionContext, _options, cancellationToken);
239+
await _connectionContext.SqlBulkCopyAsync(dataTable, temptableName, null, _options, cancellationToken);
240240
Log("End executing SqlBulkCopy.");
241241

242242
var sqlUpdateStatement = updateStatementBuilder.ToString();

src/EntityFrameworkCore.SqlServer.SimpleBulks/Extensions/DataTableExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static string GenerateTableDefinition(this DataTable table, string tableN
3636
return sql.ToString();
3737
}
3838

39-
public static void SqlBulkCopy(this DataTable dataTable, string tableName, IReadOnlyDictionary<string, string> columnNameMappings, ConnectionContext connectionContext, BulkOptions options = null)
39+
public static void SqlBulkCopy(this ConnectionContext connectionContext, DataTable dataTable, string tableName, IReadOnlyDictionary<string, string> columnNameMappings, BulkOptions options = null)
4040
{
4141
options ??= DefaultBulkOptions;
4242

@@ -55,7 +55,7 @@ public static void SqlBulkCopy(this DataTable dataTable, string tableName, IRead
5555
bulkCopy.WriteToServer(dataTable);
5656
}
5757

58-
public static async Task SqlBulkCopyAsync(this DataTable dataTable, string tableName, IReadOnlyDictionary<string, string> columnNameMappings, ConnectionContext connectionContext, BulkOptions options = null, CancellationToken cancellationToken = default)
58+
public static async Task SqlBulkCopyAsync(this ConnectionContext connectionContext, DataTable dataTable, string tableName, IReadOnlyDictionary<string, string> columnNameMappings, BulkOptions options = null, CancellationToken cancellationToken = default)
5959
{
6060
options ??= DefaultBulkOptions;
6161

src/EntityFrameworkCore.SqlServer.SimpleBulks/TempTable/TempTableBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public string Execute(IEnumerable<T> data)
8080

8181
Log($"Begin executing SqlBulkCopy. TableName: {tempTableName}");
8282

83-
dataTable.SqlBulkCopy(tempTableName, _mappingContext?.ColumnNameMappings, _connectionContext);
83+
_connectionContext.SqlBulkCopy(dataTable, tempTableName, _mappingContext?.ColumnNameMappings);
8484

8585
Log("End executing SqlBulkCopy.");
8686

@@ -110,7 +110,7 @@ public async Task<string> ExecuteAsync(IEnumerable<T> data, CancellationToken ca
110110

111111
Log($"Begin executing SqlBulkCopy. TableName: {tempTableName}");
112112

113-
await dataTable.SqlBulkCopyAsync(tempTableName, _mappingContext?.ColumnNameMappings, _connectionContext, cancellationToken: cancellationToken);
113+
await _connectionContext.SqlBulkCopyAsync(dataTable, tempTableName, _mappingContext?.ColumnNameMappings, cancellationToken: cancellationToken);
114114

115115
Log("End executing SqlBulkCopy.");
116116

0 commit comments

Comments
 (0)