Пример #1
0
        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));
        }
Пример #2
0
        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);
        }
Пример #3
0
 private static void Write(NpgsqlBulkCopy bulkCopy, DataTable table, string destinationTableName)
 {
     bulkCopy.DestinationTableName = destinationTableName;
     bulkCopy.WriteToServer(table);
 }