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);
}