@@ -9,6 +9,12 @@ namespace EntityFrameworkCore.SqlServer.SimpleBulks.Extensions;
99
1010public static class DataTableExtensions
1111{
12+ private static readonly BulkOptions DefaultBulkOptions = new BulkOptions ( )
13+ {
14+ BatchSize = 0 ,
15+ Timeout = 30 ,
16+ } ;
17+
1218 public static string GenerateTableDefinition ( this DataTable table , string tableName ,
1319 IReadOnlyDictionary < string , string > columnNameMappings ,
1420 IReadOnlyDictionary < string , string > columnTypeMappings )
@@ -32,11 +38,7 @@ public static string GenerateTableDefinition(this DataTable table, string tableN
3238
3339 public static void SqlBulkCopy ( this DataTable dataTable , string tableName , IReadOnlyDictionary < string , string > columnNameMappings , SqlConnection connection , SqlTransaction transaction , BulkOptions options = null )
3440 {
35- options ??= new BulkOptions ( )
36- {
37- BatchSize = 0 ,
38- Timeout = 30 ,
39- } ;
41+ options ??= DefaultBulkOptions ;
4042
4143 using var bulkCopy = new SqlBulkCopy ( connection , SqlBulkCopyOptions . Default , transaction )
4244 {
@@ -55,11 +57,7 @@ public static void SqlBulkCopy(this DataTable dataTable, string tableName, IRead
5557
5658 public static async Task SqlBulkCopyAsync ( this DataTable dataTable , string tableName , IReadOnlyDictionary < string , string > columnNameMappings , SqlConnection connection , SqlTransaction transaction , BulkOptions options = null , CancellationToken cancellationToken = default )
5759 {
58- options ??= new BulkOptions ( )
59- {
60- BatchSize = 0 ,
61- Timeout = 30 ,
62- } ;
60+ options ??= DefaultBulkOptions ;
6361
6462 using var bulkCopy = new SqlBulkCopy ( connection , SqlBulkCopyOptions . Default , transaction )
6563 {
0 commit comments