private void ReserveRelationIdentity (XmlSchemaElement element, XmlSchemaKeyref keyref)
{
// Basic concept came from XmlSchemaMapper.cs
string tableName = GetSelectorTarget (keyref.Selector.XPath);
string [] cols = new string [keyref.Fields.Count];
bool [] isAttrSpec = new bool [cols.Length];
int i = 0;
foreach (XmlSchemaXPath Field in keyref.Fields) {
string colName = Field.XPath;
bool isAttr = colName.Length > 0 && colName [0] == '@';
int index = colName.LastIndexOf (':');
if (index > 0)
colName = colName.Substring (index + 1);
else if (isAttr)
colName = colName.Substring (1);
colName = XmlHelper.Decode (colName);
cols [i] = colName;
isAttrSpec [i] = isAttr;
i++;
}
string constraintName = keyref.Name;
bool isNested = false;
bool isConstraintOnly = false;
if (keyref.UnhandledAttributes != null) {
foreach (XmlAttribute attr in keyref.UnhandledAttributes) {
if (attr.NamespaceURI != XmlConstants.MsdataNamespace)
continue;
switch (attr.LocalName) {
case XmlConstants.ConstraintName:
constraintName = attr.Value;
break;
case XmlConstants.IsNested:
if (attr.Value == "true")
isNested = true;
break;
case XmlConstants.ConstraintOnly:
if (attr.Value == "true")
isConstraintOnly = true;
break;
}
}
}
reservedConstraints.Add (keyref, new ConstraintStructure (
tableName, cols, isAttrSpec, constraintName,
false, keyref.Refer.Name, isNested, isConstraintOnly));
}