System.Data.TableMapping.GetColumn C# (CSharp) Method

GetColumn() public method

public GetColumn ( string name ) : DataColumn
name string
return DataColumn
		public DataColumn GetColumn (string name)
		{
			foreach (DataColumn col in Elements)
				if (col.ColumnName == name)
					return col;
			foreach (DataColumn col in Attributes)
				if (col.ColumnName == name)
					return col;
			if (SimpleContent != null && name == SimpleContent.ColumnName)
				return SimpleContent;
			if (PrimaryKey != null && name == PrimaryKey.ColumnName)
				return PrimaryKey;
			return null;
		}

Usage Example

Ejemplo n.º 1
0
        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);
        }
All Usage Examples Of System.Data.TableMapping::GetColumn