public override void LoadFromXml(XmlElement xml, ITableStructure source, ITableStructure target) { m_source = source; m_target = target; if (xml.SelectSingleNode("Script") != null) { m_script = xml.SelectSingleNode("Script").InnerText; } TableStructure t = new TableStructure(); foreach (XmlElement e in xml.SelectNodes("Column")) { ColExpr ce = ColExpr.Load(e); m_dstcols.Add(ce); t.AddColumn(new ColumnStructure { ColumnName = ce.Name, DataType = ce.GetColType(source) }, true); } m_target = t; UpdateFlags(); }
protected virtual void ProcessTableColumnsTable(TableStructure table, DataTable columns) { foreach (DataRow row in columns.Rows.SortedByKey <DataRow, int>(row => Int32.Parse(row["ORDINAL_POSITION"].ToString()))) { //NameWithSchema table = NewNameWithSchema(row["TABLE_SCHEMA"].SafeToString(), row["TABLE_NAME"].ToString()); ColumnStructure col = table.AddColumn(row["COLUMN_NAME"].ToString(), AnalyseType(new DataRowAdapter(row), m_conn, false)); LoadTableColumn(col, row); } //table.FilledMembers |= TableStructureMembers.ColumnNames | TableStructureMembers.ColumnTypes; }
public static ITableStructure GetTableStructure(this DataColumnCollection columns, string name) { TableStructure res = new TableStructure(); //res.FilledMembers |= TableStructureMembers.ColumnNames | TableStructureMembers.ColumnTypes; foreach (DataColumn col in columns.SortedByKey <DataColumn, int>(col => col.Ordinal)) { var c = res.AddColumn(col.ColumnName, TypeTool.GetDatAdminType(col.DataType)); c.IsNullable = col.AllowDBNull; c.DefaultValue = SqlExpression.ParseDefaultValue(col.DefaultValue.SafeToString(), null); } return(res); }
private ITableStructure CreateTargetStructure() { TableStructure table = new TableStructure(); foreach (DataGridViewRow row in lbtarget.Rows) { var type = GetExprType(row); if (type == null) { continue; } if (type is GenericTransform.ColumnColExprType) { string oldcol = row.Cells[2].Value.ToString(); if (m_srcformat.Columns.GetIndex(oldcol) < 0) { throw new IncorrectObjectReferenceError("DAE-00185", "s_column", oldcol); } var coldef = new ColumnStructure(m_srcformat.Columns[oldcol]); coldef.ColumnName = row.Cells[0].Value.ToString(); table.AddColumn(coldef, true); } else if (type is GenericTransform.RowNumberColExprType) { var col = new ColumnStructure(); col.ColumnName = row.Cells[0].Value.ToString(); col.DataType = new DbTypeInt(); table._Columns.Add(col); if (table.FindConstraint <IPrimaryKey>() == null && table.FindAutoIncrementColumn() == null) { var pk = new PrimaryKey(); pk.Columns.Add(new ColumnReference(col.ColumnName)); table._Constraints.Add(pk); } } else { var col = new ColumnStructure(); col.ColumnName = row.Cells[0].Value.ToString(); col.DataType = new DbTypeString(250); table._Columns.Add(col); } } return(table); }
public override void LoadFromXml(XmlElement xml, ITableStructure source, ITableStructure target) { m_source = source; m_target = target; if (m_target == null) { var t = new TableStructure(); foreach (XmlElement e in xml.SelectNodes("Column")) { int colindex = m_source.Columns.GetIndex(e.GetAttribute("src")); m_dstIndexes.Add(colindex); var newcol = new ColumnStructure(m_source.Columns[colindex]); newcol.ColumnName = e.GetAttribute("dst"); t.AddColumn(newcol, true); } m_target = t; } else { var t = new TableStructure(); foreach (XmlElement e in xml.SelectNodes("Column")) { string colname = e.GetAttribute("src"); string dstcolname = e.GetAttribute("dst"); int pos = m_source.Columns.GetIndex(colname); if (pos < 0) { throw new InternalError(String.Format("DAE-00025 Error transforming column {0}, column not found in source table", colname)); } IColumnStructure dstcol = m_target.Columns.FirstOrDefault(col => col.ColumnName == dstcolname); if (dstcol == null) { throw new InternalError(String.Format("DAE-00026 Error transforming column {0}, column not found in destination table", dstcolname)); } m_dstIndexes.Add(pos); t.AddColumn(dstcol, true); } m_target = t; } }
public void CreateColumn(IColumnStructure column) { m_table.AddColumn(column, true); m_colIndexes.Add(-1); }