Example #1
0
        public void EnsureTable(DbDataReader dbReader)
        {
            var reader = (NpgsqlDataReader)dbReader;

            lock (lockObject)
            {
                var readerColumns = PostgreeSqlDatabase.GetColumns(reader);
                if (columns != null)
                {
                    CheckColumns(columns, "original", readerColumns, "current");
                    return;
                }
                columns = readerColumns;
                if (historyMode)
                {
                    if (!target.TableExists(tableName))
                    {
                        target.CreateTable(tableName, columns);
                    }
                    else
                    {
                        var existingColumns = target.GetColumns(tableName);
                        CheckColumns(existingColumns, "existing", columns, "new");
                    }
                }
                else
                {
                    if (target.TableExists(tableName))
                    {
                        target.DropTable("dbo." + tableName);
                    }
                    target.CreateTable(tableName, columns);
                }
            }
        }
Example #2
0
 public void BeginWrite(DataColumn[] newColumns)
 {
     columns = newColumns;
     if (historyMode)
     {
         if (!target.TableExists(tableName))
         {
             target.CreateTable(tableName, newColumns);
         }
         else
         {
             var existingColumns = target.GetColumns(tableName);
             DatabaseHelpers.CheckColumnsAreEqual(existingColumns, "existing", newColumns, "new");
         }
     }
     else
     {
         if (target.TableExists(tableName))
         {
             target.DropTable("dbo." + tableName);
         }
         target.CreateTable(tableName, newColumns);
     }
 }