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));
#if NET_2_0
table.lastElementIndex = table.Elements.IndexOf (col);
#endif
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;
#if NET_2_0
table.Elements.Insert (++table.lastElementIndex, col);
#else
table.Elements.Add (col);
#endif
}