Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Simple.Data.Ado/AdoOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ public class AdoOptions : OptionsBase
private readonly int _commandTimeout;
private readonly bool _identityInsert;
private bool _fireTriggersOnBulkInserts;
private readonly int _bulkCopyTimeout;

public AdoOptions(int commandTimeout = -1, bool identityInsert = false, bool fireTriggersOnBulkInserts = false)
public AdoOptions(int commandTimeout = -1, bool identityInsert = false, bool fireTriggersOnBulkInserts = false, int bulkCopyTimeout = 30)
{
_commandTimeout = commandTimeout;
_identityInsert = identityInsert;
_fireTriggersOnBulkInserts = fireTriggersOnBulkInserts;
_bulkCopyTimeout = bulkCopyTimeout;
}

public int CommandTimeout
Expand All @@ -27,5 +29,10 @@ public bool FireTriggersOnBulkInserts
{
get { return _fireTriggersOnBulkInserts; }
}

public int BulkCopyTimeout
{
get { return _bulkCopyTimeout; }
}
}
}
5 changes: 5 additions & 0 deletions Simple.Data.SqlServer/SqlBulkInserter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public IEnumerable<IDictionary<string, object>> Insert(AdoAdapter adapter, strin
bulkCopy = new SqlBulkCopy(connection, sqlBulkCopyOptions, null);
}

if (adapter.AdoOptions != null)
{
bulkCopy.BulkCopyTimeout = adapter.AdoOptions.BulkCopyTimeout;
}

bulkCopy.DestinationTableName = adapter.GetSchema().FindTable(tableName).QualifiedName;

using (connection.MaybeDisposable())
Expand Down