diff --git a/Simple.Data.Ado/AdoOptions.cs b/Simple.Data.Ado/AdoOptions.cs index 995ae62e..31c42afd 100644 --- a/Simple.Data.Ado/AdoOptions.cs +++ b/Simple.Data.Ado/AdoOptions.cs @@ -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 @@ -27,5 +29,10 @@ public bool FireTriggersOnBulkInserts { get { return _fireTriggersOnBulkInserts; } } + + public int BulkCopyTimeout + { + get { return _bulkCopyTimeout; } + } } } \ No newline at end of file diff --git a/Simple.Data.SqlServer/SqlBulkInserter.cs b/Simple.Data.SqlServer/SqlBulkInserter.cs index 7738213e..7bb627f9 100644 --- a/Simple.Data.SqlServer/SqlBulkInserter.cs +++ b/Simple.Data.SqlServer/SqlBulkInserter.cs @@ -38,6 +38,11 @@ public IEnumerable> 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())