Skip to content

Commit 4e8a799

Browse files
committed
TableInfor
1 parent fd81013 commit 4e8a799

File tree

14 files changed

+192
-109
lines changed

14 files changed

+192
-109
lines changed

src/EntityFrameworkCore.SqlServer.SimpleBulks.ConnectionExtensionsTests/ConnectionExtensions/BulkDeleteAsyncTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ await _connection.BulkDeleteAsync(rows, row => row.Id,
7272
}
7373
else
7474
{
75-
await _connection.BulkDeleteAsync(rows, new TableInfor(_schema, "SingleKeyRows"), row => row.Id,
75+
await _connection.BulkDeleteAsync(rows, new SqlTableInfor(_schema, "SingleKeyRows"), row => row.Id,
7676
options =>
7777
{
7878
options.LogTo = _output.WriteLine;
7979
});
80-
await _connection.BulkDeleteAsync(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"), row => new { row.Id1, row.Id2 },
80+
await _connection.BulkDeleteAsync(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"), row => new { row.Id1, row.Id2 },
8181
options =>
8282
{
8383
options.LogTo = _output.WriteLine;
@@ -101,12 +101,12 @@ await _connection.BulkDeleteAsync(compositeKeyRows, ["Id1", "Id2"],
101101
}
102102
else
103103
{
104-
await _connection.BulkDeleteAsync(rows, new TableInfor(_schema, "SingleKeyRows"), "Id",
104+
await _connection.BulkDeleteAsync(rows, new SqlTableInfor(_schema, "SingleKeyRows"), "Id",
105105
options =>
106106
{
107107
options.LogTo = _output.WriteLine;
108108
});
109-
await _connection.BulkDeleteAsync(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"), ["Id1", "Id2"],
109+
await _connection.BulkDeleteAsync(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"), ["Id1", "Id2"],
110110
options =>
111111
{
112112
options.LogTo = _output.WriteLine;

src/EntityFrameworkCore.SqlServer.SimpleBulks.ConnectionExtensionsTests/ConnectionExtensions/BulkDeleteTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public void Bulk_Delete_Without_Transaction(bool useLinq, bool omitTableName)
7272
}
7373
else
7474
{
75-
_connection.BulkDelete(rows, new TableInfor(_schema, "SingleKeyRows"), row => row.Id,
75+
_connection.BulkDelete(rows, new SqlTableInfor(_schema, "SingleKeyRows"), row => row.Id,
7676
options =>
7777
{
7878
options.LogTo = _output.WriteLine;
7979
});
80-
_connection.BulkDelete(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"), row => new { row.Id1, row.Id2 },
80+
_connection.BulkDelete(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"), row => new { row.Id1, row.Id2 },
8181
options =>
8282
{
8383
options.LogTo = _output.WriteLine;
@@ -101,12 +101,12 @@ public void Bulk_Delete_Without_Transaction(bool useLinq, bool omitTableName)
101101
}
102102
else
103103
{
104-
_connection.BulkDelete(rows, new TableInfor(_schema, "SingleKeyRows"), "Id",
104+
_connection.BulkDelete(rows, new SqlTableInfor(_schema, "SingleKeyRows"), "Id",
105105
options =>
106106
{
107107
options.LogTo = _output.WriteLine;
108108
});
109-
_connection.BulkDelete(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"), ["Id1", "Id2"],
109+
_connection.BulkDelete(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"), ["Id1", "Id2"],
110110
options =>
111111
{
112112
options.LogTo = _output.WriteLine;

src/EntityFrameworkCore.SqlServer.SimpleBulks.ConnectionExtensionsTests/ConnectionExtensions/BulkInsertAsyncTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ await _connection.BulkInsertAsync(compositeKeyRows,
6666
}
6767
else
6868
{
69-
await _connection.BulkInsertAsync(rows, new TableInfor(_schema, "SingleKeyRows"),
69+
await _connection.BulkInsertAsync(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
7070
row => new { row.Column1, row.Column2, row.Column3 },
7171
row => row.Id,
7272
options =>
7373
{
7474
options.LogTo = _output.WriteLine;
7575
});
7676

77-
await _connection.BulkInsertAsync(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
77+
await _connection.BulkInsertAsync(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
7878
row => new { row.Id1, row.Id2, row.Column1, row.Column2, row.Column3 },
7979
options =>
8080
{
@@ -104,15 +104,15 @@ await _connection.BulkInsertAsync(compositeKeyRows,
104104
}
105105
else
106106
{
107-
await _connection.BulkInsertAsync(rows, new TableInfor(_schema, "SingleKeyRows"),
107+
await _connection.BulkInsertAsync(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
108108
["Column1", "Column2", "Column3"],
109109
"Id",
110110
options =>
111111
{
112112
options.LogTo = _output.WriteLine;
113113
});
114114

115-
await _connection.BulkInsertAsync(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
115+
await _connection.BulkInsertAsync(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
116116
["Id1", "Id2", "Column1", "Column2", "Column3"],
117117
options =>
118118
{

src/EntityFrameworkCore.SqlServer.SimpleBulks.ConnectionExtensionsTests/ConnectionExtensions/BulkInsertTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ public void Bulk_Insert_Without_Transaction(bool useLinq, bool omitTableName)
6666
}
6767
else
6868
{
69-
_connection.BulkInsert(rows, new TableInfor(_schema, "SingleKeyRows"),
69+
_connection.BulkInsert(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
7070
row => new { row.Column1, row.Column2, row.Column3 },
7171
row => row.Id,
7272
options =>
7373
{
7474
options.LogTo = _output.WriteLine;
7575
});
7676

77-
_connection.BulkInsert(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
77+
_connection.BulkInsert(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
7878
row => new { row.Id1, row.Id2, row.Column1, row.Column2, row.Column3 },
7979
options =>
8080
{
@@ -104,15 +104,15 @@ public void Bulk_Insert_Without_Transaction(bool useLinq, bool omitTableName)
104104
}
105105
else
106106
{
107-
_connection.BulkInsert(rows, new TableInfor(_schema, "SingleKeyRows"),
107+
_connection.BulkInsert(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
108108
["Column1", "Column2", "Column3"],
109109
"Id",
110110
options =>
111111
{
112112
options.LogTo = _output.WriteLine;
113113
});
114114

115-
_connection.BulkInsert(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
115+
_connection.BulkInsert(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
116116
["Id1", "Id2", "Column1", "Column2", "Column3"],
117117
options =>
118118
{

src/EntityFrameworkCore.SqlServer.SimpleBulks.ConnectionExtensionsTests/ConnectionExtensions/BulkUpdateAsyncTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ await _connection.BulkUpdateAsync(compositeKeyRows,
9494
}
9595
else
9696
{
97-
await _connection.BulkUpdateAsync(rows, new TableInfor(_schema, "SingleKeyRows"),
97+
await _connection.BulkUpdateAsync(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
9898
row => row.Id,
9999
row => new { row.Column3, row.Column2 },
100100
options =>
101101
{
102102
options.LogTo = _output.WriteLine;
103103
});
104104

105-
await _connection.BulkUpdateAsync(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
105+
await _connection.BulkUpdateAsync(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
106106
row => new { row.Id1, row.Id2 },
107107
row => new { row.Column3, row.Column2 },
108108
options =>
@@ -155,7 +155,7 @@ await _connection.BulkMergeAsync(compositeKeyRows,
155155
}
156156
else
157157
{
158-
await _connection.BulkMergeAsync(rows, new TableInfor(_schema, "SingleKeyRows"),
158+
await _connection.BulkMergeAsync(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
159159
row => row.Id,
160160
row => new { row.Column1, row.Column2 },
161161
row => new { row.Column1, row.Column2, row.Column3 },
@@ -164,7 +164,7 @@ await _connection.BulkMergeAsync(compositeKeyRows,
164164
options.LogTo = _output.WriteLine;
165165
});
166166

167-
await _connection.BulkMergeAsync(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
167+
await _connection.BulkMergeAsync(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
168168
row => new { row.Id1, row.Id2 },
169169
row => new { row.Column1, row.Column2, row.Column3 },
170170
row => new { row.Id1, row.Id2, row.Column1, row.Column2, row.Column3 },
@@ -197,15 +197,15 @@ await _connection.BulkUpdateAsync(compositeKeyRows,
197197
}
198198
else
199199
{
200-
await _connection.BulkUpdateAsync(rows, new TableInfor(_schema, "SingleKeyRows"),
200+
await _connection.BulkUpdateAsync(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
201201
"Id",
202202
["Column3", "Column2"],
203203
options =>
204204
{
205205
options.LogTo = _output.WriteLine;
206206
});
207207

208-
await _connection.BulkUpdateAsync(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
208+
await _connection.BulkUpdateAsync(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
209209
["Id1", "Id2"],
210210
["Column3", "Column2"],
211211
options =>
@@ -258,7 +258,7 @@ await _connection.BulkMergeAsync(compositeKeyRows,
258258
}
259259
else
260260
{
261-
await _connection.BulkMergeAsync(rows, new TableInfor(_schema, "SingleKeyRows"),
261+
await _connection.BulkMergeAsync(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
262262
"Id",
263263
["Column1", "Column2"],
264264
["Column1", "Column2", "Column3"],
@@ -267,7 +267,7 @@ await _connection.BulkMergeAsync(compositeKeyRows,
267267
options.LogTo = _output.WriteLine;
268268
});
269269

270-
await _connection.BulkMergeAsync(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
270+
await _connection.BulkMergeAsync(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
271271
["Id1", "Id2"],
272272
["Column1", "Column2", "Column3"],
273273
["Id1", "Id2", "Column1", "Column2", "Column3"],

src/EntityFrameworkCore.SqlServer.SimpleBulks.ConnectionExtensionsTests/ConnectionExtensions/BulkUpdateTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ public void Bulk_Update_Without_Transaction(bool useLinq, bool omitTableName)
9494
}
9595
else
9696
{
97-
_connection.BulkUpdate(rows, new TableInfor(_schema, "SingleKeyRows"),
97+
_connection.BulkUpdate(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
9898
row => row.Id,
9999
row => new { row.Column3, row.Column2 },
100100
options =>
101101
{
102102
options.LogTo = _output.WriteLine;
103103
});
104104

105-
_connection.BulkUpdate(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
105+
_connection.BulkUpdate(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
106106
row => new { row.Id1, row.Id2 },
107107
row => new { row.Column3, row.Column2 },
108108
options =>
@@ -155,7 +155,7 @@ public void Bulk_Update_Without_Transaction(bool useLinq, bool omitTableName)
155155
}
156156
else
157157
{
158-
_connection.BulkMerge(rows, new TableInfor(_schema, "SingleKeyRows"),
158+
_connection.BulkMerge(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
159159
row => row.Id,
160160
row => new { row.Column1, row.Column2 },
161161
row => new { row.Column1, row.Column2, row.Column3 },
@@ -164,7 +164,7 @@ public void Bulk_Update_Without_Transaction(bool useLinq, bool omitTableName)
164164
options.LogTo = _output.WriteLine;
165165
});
166166

167-
_connection.BulkMerge(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
167+
_connection.BulkMerge(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
168168
row => new { row.Id1, row.Id2 },
169169
row => new { row.Column1, row.Column2, row.Column3 },
170170
row => new { row.Id1, row.Id2, row.Column1, row.Column2, row.Column3 },
@@ -197,15 +197,15 @@ public void Bulk_Update_Without_Transaction(bool useLinq, bool omitTableName)
197197
}
198198
else
199199
{
200-
_connection.BulkUpdate(rows, new TableInfor(_schema, "SingleKeyRows"),
200+
_connection.BulkUpdate(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
201201
"Id",
202202
["Column3", "Column2"],
203203
options =>
204204
{
205205
options.LogTo = _output.WriteLine;
206206
});
207207

208-
_connection.BulkUpdate(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
208+
_connection.BulkUpdate(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
209209
["Id1", "Id2"],
210210
["Column3", "Column2"],
211211
options =>
@@ -258,7 +258,7 @@ public void Bulk_Update_Without_Transaction(bool useLinq, bool omitTableName)
258258
}
259259
else
260260
{
261-
_connection.BulkMerge(rows, new TableInfor(_schema, "SingleKeyRows"),
261+
_connection.BulkMerge(rows, new SqlTableInfor(_schema, "SingleKeyRows"),
262262
"Id",
263263
["Column1", "Column2"],
264264
["Column1", "Column2", "Column3"],
@@ -267,7 +267,7 @@ public void Bulk_Update_Without_Transaction(bool useLinq, bool omitTableName)
267267
options.LogTo = _output.WriteLine;
268268
});
269269

270-
_connection.BulkMerge(compositeKeyRows, new TableInfor(_schema, "CompositeKeyRows"),
270+
_connection.BulkMerge(compositeKeyRows, new SqlTableInfor(_schema, "CompositeKeyRows"),
271271
["Id1", "Id2"],
272272
["Column1", "Column2", "Column3"],
273273
["Id1", "Id2", "Column1", "Column2", "Column3"],

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public BulkDeleteResult SingleDelete(T dataToDelete)
160160

161161
using var deleteCommand = _connection.CreateTextCommand(_transaction, deleteStatement, _options);
162162

163-
dataToDelete.ToSqlParameters(_idColumns, valueConverters: _valueConverters).ForEach(x => deleteCommand.Parameters.Add(x));
163+
_table.CreateSqlParameters(deleteCommand, dataToDelete, _idColumns).ForEach(x => deleteCommand.Parameters.Add(x));
164164

165165
_connection.EnsureOpen();
166166

@@ -243,7 +243,7 @@ public async Task<BulkDeleteResult> SingleDeleteAsync(T dataToDelete, Cancellati
243243

244244
using var deleteCommand = _connection.CreateTextCommand(_transaction, deleteStatement, _options);
245245

246-
dataToDelete.ToSqlParameters(_idColumns, valueConverters: _valueConverters).ForEach(x => deleteCommand.Parameters.Add(x));
246+
_table.CreateSqlParameters(deleteCommand, dataToDelete, _idColumns).ForEach(x => deleteCommand.Parameters.Add(x));
247247

248248
await _connection.EnsureOpenAsync(cancellationToken);
249249

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ public void SingleInsert(T dataToInsert)
300300
var insertStatement = insertStatementBuilder.ToString();
301301

302302
using var insertCommand = _connection.CreateTextCommand(_transaction, insertStatement, _options);
303-
dataToInsert.ToSqlParameters(columnsToInsert, valueConverters: _valueConverters).ForEach(x => insertCommand.Parameters.Add(x));
303+
304+
_table.CreateSqlParameters(insertCommand, dataToInsert, columnsToInsert).ForEach(x => insertCommand.Parameters.Add(x));
304305

305306
Log($"Begin inserting: {Environment.NewLine}{insertStatement}");
306307

@@ -498,7 +499,7 @@ public async Task SingleInsertAsync(T dataToInsert, CancellationToken cancellati
498499
var insertStatement = insertStatementBuilder.ToString();
499500

500501
using var insertCommand = _connection.CreateTextCommand(_transaction, insertStatement, _options);
501-
dataToInsert.ToSqlParameters(columnsToInsert, valueConverters: _valueConverters).ForEach(x => insertCommand.Parameters.Add(x));
502+
_table.CreateSqlParameters(insertCommand, dataToInsert, columnsToInsert).ForEach(x => insertCommand.Parameters.Add(x));
502503

503504
Log($"Begin inserting: {Environment.NewLine}{insertStatement}");
504505

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ public BulkMergeResult SingleMerge(T data)
348348

349349
using (var updateCommand = _connection.CreateTextCommand(_transaction, sqlMergeStatement, _options))
350350
{
351-
data.ToSqlParameters(propertyNames, valueConverters: _valueConverters)
352-
.ForEach(x => updateCommand.Parameters.Add(x));
351+
_table.CreateSqlParameters(updateCommand, data, propertyNames)
352+
.ForEach(x => updateCommand.Parameters.Add(x));
353353

354354
using var reader = updateCommand.ExecuteReader();
355355

@@ -618,7 +618,7 @@ public async Task<BulkMergeResult> SingleMergeAsync(T data, CancellationToken ca
618618

619619
using (var updateCommand = _connection.CreateTextCommand(_transaction, sqlMergeStatement, _options))
620620
{
621-
data.ToSqlParameters(propertyNames, valueConverters: _valueConverters)
621+
_table.CreateSqlParameters(updateCommand, data, propertyNames)
622622
.ForEach(x => updateCommand.Parameters.Add(x));
623623

624624
using var reader = await updateCommand.ExecuteReaderAsync(cancellationToken);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public BulkUpdateResult SingleUpdate(T dataToUpdate)
184184

185185
using var updateCommand = _connection.CreateTextCommand(_transaction, sqlUpdateStatement, _options);
186186

187-
dataToUpdate.ToSqlParameters(propertyNamesIncludeId, valueConverters: _valueConverters).ForEach(x => updateCommand.Parameters.Add(x));
187+
_table.CreateSqlParameters(updateCommand, dataToUpdate, propertyNamesIncludeId).ForEach(x => updateCommand.Parameters.Add(x));
188188

189189
_connection.EnsureOpen();
190190

@@ -309,7 +309,7 @@ public async Task<BulkUpdateResult> SingleUpdateAsync(T dataToUpdate, Cancellati
309309

310310
using var updateCommand = _connection.CreateTextCommand(_transaction, sqlUpdateStatement, _options);
311311

312-
dataToUpdate.ToSqlParameters(propertyNamesIncludeId, valueConverters: _valueConverters).ForEach(x => updateCommand.Parameters.Add(x));
312+
_table.CreateSqlParameters(updateCommand, dataToUpdate, propertyNamesIncludeId).ForEach(x => updateCommand.Parameters.Add(x));
313313

314314
await _connection.EnsureOpenAsync(cancellationToken);
315315

0 commit comments

Comments
 (0)