Пример #1
0
        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);
        }
Пример #2
0
 public SimpleBulkCopy(
     string connectionString,
     BulkCopyTableDefinition <T> definition,
     int bulkCopyTimeout = 3600)
 {
     _connectionString = connectionString;
     _definition       = definition;
     _bulkCopyTimeout  = bulkCopyTimeout;
 }
Пример #3
0
        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);
        }