private static SqlBulkCopy ConfigureBulkCopy(SqlConnection connection, BulkCopyTableDefinition <T> definition, int bulkCopyTimeout) { var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.CheckConstraints | SqlBulkCopyOptions.FireTriggers, null); bulkCopy.BulkCopyTimeout = bulkCopyTimeout; bulkCopy.DestinationTableName = $"[dbo].[{definition.TableName}]"; bulkCopy.BatchSize = InitialSaveBatchSize; return(bulkCopy); }
public SimpleBulkCopy( string connectionString, BulkCopyTableDefinition <T> definition, int bulkCopyTimeout = 3600) { _connectionString = connectionString; _definition = definition; _bulkCopyTimeout = bulkCopyTimeout; }
private static DataTable ConfigureDataTable(BulkCopyTableDefinition <T> definition) { var table = new DataTable(definition.TableName); foreach (var column in definition.Schema) { table.Columns.Add(column.FieldName, column.PropertyType); } return(table); }