private void InferColumnElement(TableMapping table, XmlElement el) { string localName = XmlHelper.Decode(el.LocalName); DataColumn col = table.GetColumn(localName); if (col != null) { if (col.ColumnMapping != MappingType.Element) { throw new DataException(String.Format("Column {0} is already mapped to {1}.", localName, col.ColumnMapping)); } table.lastElementIndex = table.Elements.IndexOf(col); return; } if (table.ChildTables [localName] != null) { // Child is already mapped, or inferred as a table // (in that case, that takes precedence than // this simple column inference.) return; } col = new DataColumn(localName, typeof(string)); col.Namespace = el.NamespaceURI; col.Prefix = el.Prefix; table.Elements.Insert(++table.lastElementIndex, col); }
private void CheckExtraneousElementColumn(TableMapping parentTable, XmlElement el) { if (parentTable == null) { return; } string localName = XmlHelper.Decode(el.LocalName); DataColumn elc = parentTable.GetColumn(localName); if (elc != null) { parentTable.RemoveElementColumn(localName); } }
private DataColumn GetMappedColumn(TableMapping table, string name, string prefix, string ns, MappingType type, Type optColType) { DataColumn col = table.GetColumn(name); // Infer schema if (col == null) { col = new DataColumn(name); col.Prefix = prefix; col.Namespace = ns; col.ColumnMapping = type; switch (type) { case MappingType.Element: table.Elements.Add(col); break; case MappingType.Attribute: table.Attributes.Add(col); break; case MappingType.SimpleContent: table.SimpleContent = col; break; case MappingType.Hidden: // To generate parent key col.DataType = optColType; table.ReferenceKey = col; break; } } else if (col.ColumnMapping != type) // Check mapping type { throw new DataException(String.Format("There are already another column that has different mapping type. Column is {0}, existing mapping type is {1}", col.ColumnName, col.ColumnMapping)); } return(col); }
private DataColumn GetMappedColumn (TableMapping table, string name, string prefix, string ns, MappingType type, Type optColType) { DataColumn col = table.GetColumn (name); // Infer schema if (col == null) { col = new DataColumn (name); col.Prefix = prefix; col.Namespace = ns; col.ColumnMapping = type; switch (type) { case MappingType.Element: table.Elements.Add (col); break; case MappingType.Attribute: table.Attributes.Add (col); break; case MappingType.SimpleContent: table.SimpleContent = col; break; case MappingType.Hidden: // To generate parent key col.DataType = optColType; table.ReferenceKey = col; break; } } else if (col.ColumnMapping != type) // Check mapping type throw new DataException (String.Format ("There are already another column that has different mapping type. Column is {0}, existing mapping type is {1}", col.ColumnName, col.ColumnMapping)); return col; }
private void CheckExtraneousElementColumn (TableMapping parentTable, XmlElement el) { if (parentTable == null) return; string localName = XmlHelper.Decode (el.LocalName); DataColumn elc = parentTable.GetColumn (localName); if (elc != null) parentTable.RemoveElementColumn (localName); }
private void InferColumnElement (TableMapping table, XmlElement el) { string localName = XmlHelper.Decode (el.LocalName); DataColumn col = table.GetColumn (localName); if (col != null) { if (col.ColumnMapping != MappingType.Element) throw new DataException (String.Format ("Column {0} is already mapped to {1}.", localName, col.ColumnMapping)); table.lastElementIndex = table.Elements.IndexOf (col); return; } if (table.ChildTables [localName] != null) // Child is already mapped, or inferred as a table // (in that case, that takes precedence than // this simple column inference.) return; col = new DataColumn (localName, typeof (string)); col.Namespace = el.NamespaceURI; col.Prefix = el.Prefix; table.Elements.Insert (++table.lastElementIndex, col); }