@@ -25,16 +25,17 @@ public IEnumerable<IDictionary<string, object>> Insert(AdoAdapter adapter, strin
2525
2626 SqlConnection connection ;
2727 SqlBulkCopy bulkCopy ;
28+ var sqlBulkCopyOptions = BuildBulkCopyOptions ( adapter ) ;
2829
2930 if ( transaction != null )
3031 {
3132 connection = ( SqlConnection ) transaction . Connection ;
32- bulkCopy = new SqlBulkCopy ( connection , SqlBulkCopyOptions . Default , ( SqlTransaction ) transaction ) ;
33+ bulkCopy = new SqlBulkCopy ( connection , sqlBulkCopyOptions , ( SqlTransaction ) transaction ) ;
3334 }
3435 else
3536 {
3637 connection = ( SqlConnection ) adapter . CreateConnection ( ) ;
37- bulkCopy = new SqlBulkCopy ( connection ) ;
38+ bulkCopy = new SqlBulkCopy ( connection , sqlBulkCopyOptions , null ) ;
3839 }
3940
4041 bulkCopy . DestinationTableName = adapter . GetSchema ( ) . FindTable ( tableName ) . QualifiedName ;
@@ -67,6 +68,20 @@ public IEnumerable<IDictionary<string, object>> Insert(AdoAdapter adapter, strin
6768 return null ;
6869 }
6970
71+ private SqlBulkCopyOptions BuildBulkCopyOptions ( AdoAdapter adapter )
72+ {
73+ var options = SqlBulkCopyOptions . Default ;
74+
75+ if ( adapter . AdoOptions != null )
76+ {
77+ options |= ( adapter . AdoOptions . FireTriggersOnBulkInserts
78+ ? SqlBulkCopyOptions . FireTriggers
79+ : SqlBulkCopyOptions . Default ) ;
80+ }
81+
82+ return options ;
83+ }
84+
7085 private DataTable CreateDataTable ( AdoAdapter adapter , string tableName , ICollection < string > keys , SqlBulkCopy bulkCopy )
7186 {
7287 var table = adapter . GetSchema ( ) . FindTable ( tableName ) ;
0 commit comments