System.Data.XmlSchemaDataImporter.AddParentKeyColumn C# (CSharp) Метод

AddParentKeyColumn() приватный Метод

private AddParentKeyColumn ( XmlSchemaElement parent, XmlSchemaElement el, DataColumn col ) : void
parent System.Xml.Schema.XmlSchemaElement
el System.Xml.Schema.XmlSchemaElement
col DataColumn
Результат void
		private void AddParentKeyColumn (XmlSchemaElement parent, XmlSchemaElement el, DataColumn col)
		{
			// check existing primary key
			if (currentTable.Table.PrimaryKey.Length > 0)
				throw new DataException (String.Format ("There is already primary key columns in the table \"{0}\".", currentTable.Table.TableName));

			if (currentTable.PrimaryKey != null) {
				// fill pk column info and return
				col.ColumnName = currentTable.PrimaryKey.ColumnName;
				col.ColumnMapping = currentTable.PrimaryKey.ColumnMapping;
				col.Namespace = currentTable.PrimaryKey.Namespace;
				col.DataType = currentTable.PrimaryKey.DataType;
				col.AutoIncrement = currentTable.PrimaryKey.AutoIncrement;
				col.AllowDBNull = currentTable.PrimaryKey.AllowDBNull;
				
				ImportColumnMetaInfo (el, el.QualifiedName, col);
				return;
			}

			// check name identity
			string name = XmlHelper.Decode (parent.QualifiedName.Name) + "_Id";
			int count = 0;
			while (currentTable.ContainsColumn (name))
				name = String.Format ("{0}_{1}", name, count++);

			col.ColumnName = name;
			col.ColumnMapping = MappingType.Hidden;
			col.Namespace = parent.QualifiedName.Namespace;
			col.DataType = typeof (int);
			col.AutoIncrement = true;
			col.AllowDBNull = false;
			ImportColumnMetaInfo (el, el.QualifiedName, col);
			
			AddColumn (col);
			currentTable.PrimaryKey = col;
		}