protected override TablePair Write(IDbConnection connection, DataTable table, string tempTableName = null) { var bulkCopy = new NpgsqlBulkCopy(connection.AsNpgsqlConnection(), TableDefinitionGenerator as IPostgresTableDefinitionGenerator); if (string.IsNullOrWhiteSpace(tempTableName)) { tempTableName = CreateTempSchema(connection, table).TableName; } Write(bulkCopy, table, tempTableName); return(new TablePair(table.TableName, tempTableName)); }
protected override IList <TablePair> Write(IDbConnection connection, DataSet data, IEnumerable <TablePair> tempTableMap = null) { var result = new List <TablePair>(); var bulkCopy = new NpgsqlBulkCopy(connection.AsNpgsqlConnection(), TableDefinitionGenerator as IPostgresTableDefinitionGenerator); var tempTables = tempTableMap?.ToDictionary(x => x.LiveTable, x => x.TempTable); string tempTableName = null; foreach (DataTable table in data.Tables) { if (!(tempTables?.TryGetValue(table.TableName, out tempTableName) ?? false) || string.IsNullOrWhiteSpace(tempTableName)) { tempTableName = CreateTempSchema(connection, table).TableName; } Write(bulkCopy, table, tempTableName); result.Add(new TablePair(table.TableName, tempTableName)); } return(result); }
private static void Write(NpgsqlBulkCopy bulkCopy, DataTable table, string destinationTableName) { bulkCopy.DestinationTableName = destinationTableName; bulkCopy.WriteToServer(table); }