@@ -293,6 +293,179 @@ public static Task<ITempTableQuery<T>> BulkInsertIntoTempTableAsync<T>(
293
293
return executor . BulkInsertIntoTempTableAsync ( entities , options , cancellationToken ) ;
294
294
}
295
295
296
+ /// <summary>
297
+ /// Copies <paramref name="values"/> into a temp table and returns the query for accessing the inserted records.
298
+ /// </summary>
299
+ /// <param name="ctx">Database context.</param>
300
+ /// <param name="values">Values to insert.</param>
301
+ /// <param name="tempTable">Temp table to insert into.</param>
302
+ /// <param name="options">Options.</param>
303
+ /// <param name="cancellationToken">Cancellation token.</param>
304
+ /// <typeparam name="TColumn1">Type of the values to insert.</typeparam>
305
+ /// <returns>A query for accessing the inserted values.</returns>
306
+ /// <exception cref="ArgumentNullException"> <paramref name="ctx"/> or <paramref name="values"/> is <c>null</c>.</exception>
307
+ public static Task BulkInsertValuesIntoTempTableAsync < TColumn1 > (
308
+ this DbContext ctx ,
309
+ IEnumerable < TColumn1 > values ,
310
+ ITempTableReference tempTable ,
311
+ ITempTableBulkInsertOptions ? options ,
312
+ CancellationToken cancellationToken = default )
313
+ {
314
+ ArgumentNullException . ThrowIfNull ( values ) ;
315
+
316
+ var executor = ctx . GetService < ITempTableBulkInsertExecutor > ( ) ;
317
+
318
+ return executor . BulkInsertValuesIntoTempTableAsync ( values , tempTable , options , cancellationToken ) ;
319
+ }
320
+
321
+ /// <summary>
322
+ /// Copies <paramref name="values"/> into a temp table and returns the query for accessing the inserted records.
323
+ /// </summary>
324
+ /// <param name="ctx">Database context.</param>
325
+ /// <param name="values">Values to insert.</param>
326
+ /// <param name="tempTable">Temp table to insert into.</param>
327
+ /// <param name="options">Options.</param>
328
+ /// <param name="cancellationToken">Cancellation token.</param>
329
+ /// <typeparam name="TColumn1">Type of the values to insert.</typeparam>
330
+ /// <returns>A query for accessing the inserted values.</returns>
331
+ /// <exception cref="ArgumentNullException"> <paramref name="ctx"/> or <paramref name="values"/> is <c>null</c>.</exception>
332
+ public static Task BulkInsertValuesIntoTempTableAsync < TColumn1 > (
333
+ this DbContext ctx ,
334
+ IEnumerable < TColumn1 > values ,
335
+ ITempTableReference tempTable ,
336
+ IBulkInsertOptions ? options = null ,
337
+ CancellationToken cancellationToken = default )
338
+ {
339
+ ArgumentNullException . ThrowIfNull ( values ) ;
340
+
341
+ var executor = ctx . GetService < ITempTableBulkInsertExecutor > ( ) ;
342
+
343
+ return executor . BulkInsertValuesIntoTempTableAsync ( values , tempTable , options , cancellationToken ) ;
344
+ }
345
+
346
+ /// <summary>
347
+ /// Copies <paramref name="values"/> into a temp table and returns the query for accessing the inserted records.
348
+ /// </summary>
349
+ /// <param name="ctx">Database context.</param>
350
+ /// <param name="values">Values to insert.</param>
351
+ /// <param name="tempTable">Temp table to insert into.</param>
352
+ /// <param name="options">Options.</param>
353
+ /// <param name="cancellationToken">Cancellation token.</param>
354
+ /// <typeparam name="TColumn1">Type of the column 1.</typeparam>
355
+ /// <typeparam name="TColumn2">Type of the column 2.</typeparam>
356
+ /// <returns>A query for accessing the inserted values.</returns>
357
+ /// <exception cref="ArgumentNullException"> <paramref name="ctx"/> or <paramref name="values"/> is <c>null</c>.</exception>
358
+ public static Task BulkInsertValuesIntoTempTableAsync < TColumn1 , TColumn2 > (
359
+ this DbContext ctx ,
360
+ IEnumerable < ( TColumn1 column1 , TColumn2 column2 ) > values ,
361
+ ITempTableReference tempTable ,
362
+ ITempTableBulkInsertOptions ? options ,
363
+ CancellationToken cancellationToken = default )
364
+ {
365
+ ArgumentNullException . ThrowIfNull ( values ) ;
366
+
367
+ var entities = values . Select ( t => new TempTable < TColumn1 , TColumn2 > ( t . column1 , t . column2 ) ) ;
368
+
369
+ return ctx . BulkInsertIntoTempTableAsync ( entities , tempTable , options , cancellationToken ) ;
370
+ }
371
+
372
+ /// <summary>
373
+ /// Copies <paramref name="values"/> into a temp table and returns the query for accessing the inserted records.
374
+ /// </summary>
375
+ /// <param name="ctx">Database context.</param>
376
+ /// <param name="values">Values to insert.</param>
377
+ /// <param name="tempTable">Temp table to insert into.</param>
378
+ /// <param name="options">Options.</param>
379
+ /// <param name="cancellationToken">Cancellation token.</param>
380
+ /// <typeparam name="TColumn1">Type of the column 1.</typeparam>
381
+ /// <typeparam name="TColumn2">Type of the column 2.</typeparam>
382
+ /// <returns>A query for accessing the inserted values.</returns>
383
+ /// <exception cref="ArgumentNullException"> <paramref name="ctx"/> or <paramref name="values"/> is <c>null</c>.</exception>
384
+ public static Task BulkInsertValuesIntoTempTableAsync < TColumn1 , TColumn2 > (
385
+ this DbContext ctx ,
386
+ IEnumerable < ( TColumn1 column1 , TColumn2 column2 ) > values ,
387
+ ITempTableReference tempTable ,
388
+ IBulkInsertOptions ? options = null ,
389
+ CancellationToken cancellationToken = default )
390
+ {
391
+ ArgumentNullException . ThrowIfNull ( values ) ;
392
+
393
+ var entities = values . Select ( t => new TempTable < TColumn1 , TColumn2 > ( t . column1 , t . column2 ) ) ;
394
+
395
+ return ctx . BulkInsertIntoTempTableAsync ( entities , tempTable , options , cancellationToken ) ;
396
+ }
397
+
398
+ /// <summary>
399
+ /// Copies <paramref name="entities"/> into a temp table and returns the query for accessing the inserted records.
400
+ /// </summary>
401
+ /// <param name="ctx">Database context.</param>
402
+ /// <param name="entities">Entities to insert.</param>
403
+ /// <param name="tempTable">Temp table to insert into.</param>
404
+ /// <param name="propertiesToInsert">Properties to insert. If <c>null</c> then all properties are used.</param>
405
+ /// <param name="cancellationToken">Cancellation token.</param>
406
+ /// <typeparam name="T">Entity type.</typeparam>
407
+ /// <returns>A query for accessing the inserted values.</returns>
408
+ /// <exception cref="ArgumentNullException"> <paramref name="ctx"/> or <paramref name="entities"/> is <c>null</c>.</exception>
409
+ public static Task BulkInsertIntoTempTableAsync < T > (
410
+ this DbContext ctx ,
411
+ IEnumerable < T > entities ,
412
+ ITempTableReference tempTable ,
413
+ Expression < Func < T , object ? > > ? propertiesToInsert = null ,
414
+ CancellationToken cancellationToken = default )
415
+ where T : class
416
+ {
417
+ var executor = ctx . GetService < ITempTableBulkInsertExecutor > ( ) ;
418
+ var options = executor . CreateBulkInsertOptions ( propertiesToInsert is null ? null : IEntityPropertiesProvider . Include ( propertiesToInsert ) ) ;
419
+
420
+ return executor . BulkInsertIntoTempTableAsync ( entities , tempTable , options , cancellationToken ) ;
421
+ }
422
+
423
+ /// <summary>
424
+ /// Copies <paramref name="entities"/> into a temp table and returns the query for accessing the inserted records.
425
+ /// </summary>
426
+ /// <param name="ctx">Database context.</param>
427
+ /// <param name="entities">Entities to insert.</param>
428
+ /// <param name="tempTable">Temp table to insert into.</param>
429
+ /// <param name="options">Options.</param>
430
+ /// <param name="cancellationToken">Cancellation token.</param>
431
+ /// <typeparam name="T">Entity type.</typeparam>
432
+ /// <exception cref="ArgumentNullException"> <paramref name="ctx"/> or <paramref name="entities"/> is <c>null</c>.</exception>
433
+ public static Task BulkInsertIntoTempTableAsync < T > (
434
+ this DbContext ctx ,
435
+ IEnumerable < T > entities ,
436
+ ITempTableReference tempTable ,
437
+ ITempTableBulkInsertOptions ? options ,
438
+ CancellationToken cancellationToken = default )
439
+ where T : class
440
+ {
441
+ var executor = ctx . GetService < ITempTableBulkInsertExecutor > ( ) ;
442
+
443
+ return executor . BulkInsertIntoTempTableAsync ( entities , tempTable , options , cancellationToken ) ;
444
+ }
445
+
446
+ /// <summary>
447
+ /// Copies <paramref name="entities"/> into a temp table and returns the query for accessing the inserted records.
448
+ /// </summary>
449
+ /// <param name="ctx">Database context.</param>
450
+ /// <param name="entities">Entities to insert.</param>
451
+ /// <param name="tempTable">Temp table to insert into.</param>
452
+ /// <param name="options">Options.</param>
453
+ /// <param name="cancellationToken">Cancellation token.</param>
454
+ /// <typeparam name="T">Entity type.</typeparam>
455
+ /// <exception cref="ArgumentNullException"> <paramref name="ctx"/> or <paramref name="entities"/> is <c>null</c>.</exception>
456
+ public static Task BulkInsertIntoTempTableAsync < T > (
457
+ this DbContext ctx ,
458
+ IEnumerable < T > entities ,
459
+ ITempTableReference tempTable ,
460
+ IBulkInsertOptions ? options ,
461
+ CancellationToken cancellationToken = default )
462
+ where T : class
463
+ {
464
+ var executor = ctx . GetService < ITempTableBulkInsertExecutor > ( ) ;
465
+
466
+ return executor . BulkInsertIntoTempTableAsync ( entities , tempTable , options , cancellationToken ) ;
467
+ }
468
+
296
469
/// <summary>
297
470
/// Truncates the table of the entity of type <typeparamref name="T"/>.
298
471
/// </summary>
0 commit comments