Skip to content

Commit cc9e7f2

Browse files
Merge branch 'master' of github.com:SebastianStehle/PhenX.EntityFrameworkCore.BulkInsert into mysql
# Conflicts: # src/PhenX.EntityFrameworkCore.BulkInsert/Options/BulkInsertOptions.cs
2 parents 340516c + 687df08 commit cc9e7f2

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/PhenX.EntityFrameworkCore.BulkInsert.SqlServer/SqlServerBulkInsertProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ CancellationToken ctk
4444
using var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.TableLock, sqlTransaction);
4545
bulkCopy.DestinationTableName = tableName;
4646
bulkCopy.BatchSize = options.BatchSize ?? 50_000;
47-
bulkCopy.BulkCopyTimeout = 60;
47+
bulkCopy.BulkCopyTimeout = options.GetCopyTimeoutInSeconds();
4848

4949
foreach (var prop in properties)
5050
{

src/PhenX.EntityFrameworkCore.BulkInsert/Options/BulkInsertOptions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,14 @@ public class BulkInsertOptions
3737
/// Indicates if also generated columns should be copied. This is useful for upsert operations.
3838
/// </summary>
3939
public bool CopyGeneratedColumns { get; set; }
40+
41+
/// <summary>
42+
/// The timeout to copy records.
43+
/// </summary>
44+
public TimeSpan CopyTimeout = TimeSpan.FromMinutes(10);
45+
46+
internal int GetCopyTimeoutInSeconds()
47+
{
48+
return Math.Max(0, (int)CopyTimeout.TotalSeconds);
49+
}
4050
}

0 commit comments

Comments
 (0)