Ejemplo n.º 1
0
        private void _PopulateConstraints()
        {
            int index = 0;
            foreach (XPathNavigator conNav in _tableNavigator.Select("rc:Constraints/rc:PrimaryKeyConstraint", _vulcanConfig.NamespaceManager))
            {
                _constraintList.Add(_ParseSimpleConstraint(conNav,true,index));
                index++;
            }

            index = 0;
            foreach (XPathNavigator conNav in _tableNavigator.Select("rc:Constraints/rc:Constraint", _vulcanConfig.NamespaceManager))
            {
                _constraintList.Add(_ParseSimpleConstraint(conNav, false, index));
                index++;
            }

            foreach (XPathNavigator fkCon in _tableNavigator.Select("rc:Constraints/rc:ForeignKeyConstraint", _vulcanConfig.NamespaceManager))
            {
                Column localColumn = new Column();
                Column foreignColumn = new Column();
                foreach (XPathNavigator nav in fkCon.Select("rc:LocalColumn/@*", _vulcanConfig.NamespaceManager))
                {
                    localColumn.Properties[nav.Name] = nav.Value;
                }
                foreach (XPathNavigator nav in fkCon.Select("rc:ForeignColumn/@*", _vulcanConfig.NamespaceManager))
                {
                    foreignColumn.Properties[nav.Name] = nav.Value;
                }
                string fkName = String.Format(System.Globalization.CultureInfo.InvariantCulture,"FK_{0}_{1}_{2}_{3}",_name,localColumn.Name,foreignColumn.Properties["Table"],foreignColumn.Name);
                ForeignKeyConstraint fkc = new ForeignKeyConstraint(fkName, localColumn, foreignColumn, foreignColumn.Properties["Table"]);
                _constraintList.Add(fkc);
            }
        }
Ejemplo n.º 2
0
        private void _ParseKeyColumn()
        {
            XPathNavigator keyColumnNav = _tableNavigator.SelectSingleNode("rc:KeyColumn", _vulcanConfig.NamespaceManager);

            if (keyColumnNav != null)
            {
                string name = keyColumnNav.SelectSingleNode("@Name").Value;
                string type = keyColumnNav.SelectSingleNode("@Type").Value;

                if(this._columnLookup.ContainsKey(name))
                {
                   this._keyColumn = this._columnLookup[name];

                    switch(type)
                    {
                        case "PrimaryKey":
                            this._keyColumnType = KeyColumnType.PrimaryKey;
                            break;
                        case "Identity":
                            this._keyColumnType = KeyColumnType.Identity;
                            break;
                        default:
                            Message.Trace(Severity.Error,"Unknown key column type {0}",type);
                            this._keyColumnType = KeyColumnType.None;
                            break;
                    }
                }
                else
                {
                     Message.Trace(Severity.Warning,"Invalid key column {0} in {1}. Skipping",name,this.Name);
                    return;
                }
            }
            else
            {
                _keyColumn = null;
                _keyColumnType = KeyColumnType.None;
            }
        }
Ejemplo n.º 3
0
        private SimpleConstraint _ParseSimpleConstraint(XPathNavigator simpleConstraintNav, bool isPrimaryKey, int index)
        {
            SimpleConstraint sc;
            List<Column> localColumnList = new List<Column>();

            foreach (XPathNavigator colNav in simpleConstraintNav.Select("rc:Column", _vulcanConfig.NamespaceManager))
            {
                Column c = new Column();
                foreach (XPathNavigator nav in colNav.Select("@*"))
                {
                    c.Properties.Add(nav.Name, nav.Value);
                }
                localColumnList.Add(c);
            }

            if (isPrimaryKey)
            {
                string name = String.Format(System.Globalization.CultureInfo.InvariantCulture, "PK_{0}_{1}", _name, index, localColumnList);
                sc = new PrimaryKeyConstraint(name, localColumnList);
            }
            else
            {
                string name = String.Format(System.Globalization.CultureInfo.InvariantCulture, "CON_{0}_{1}", _name, index, localColumnList);
                sc = new SimpleConstraint(name, localColumnList);
            }

            foreach (XPathNavigator attributeNav in simpleConstraintNav.Select("@*"))
            {
                sc.Properties.Add(attributeNav.Name, attributeNav.Value);
            }
            return sc;
        }
Ejemplo n.º 4
0
 private void _ParseColumns()
 {
     foreach (XPathNavigator colNav in _tableNavigator.Select("rc:Columns/rc:Column", _vulcanConfig.NamespaceManager))
     {
         Column c = new Column();
         foreach (XPathNavigator nav in colNav.Select("@*"))
         {
             c.Properties.Add(nav.Name, nav.Value);
         }
         if(!_columnLookup.ContainsKey(c.Properties["Name"]))
         {
         _columnLookup.Add(c.Properties["Name"], c);
         }
         else
         {
             Message.Trace(Severity.Error,"Duplicate column {0} in {1}",c.Properties["Name"],this.Name);
             return;
         }
     }
 }
Ejemplo n.º 5
0
 public SimpleConstraint(string name, Column c)
     : base(name)
 {
     _columnList = new List<Column>();
     _columnList.Add(c);
 }
Ejemplo n.º 6
0
 public PrimaryKeyConstraint(string name, Column c)
     : base(name,c)
 {
 }
Ejemplo n.º 7
0
 public ForeignKeyConstraint(string name, Column localColumn, Column foreignColumn, string foreignTable)
     : base(name)
 {
     _localColumn = localColumn;
     _foreignColumn = foreignColumn;
     _foreignTable = foreignTable;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Performs a deep clone of the Column
 /// </summary>
 /// <returns>Column which was cloned.</returns>
 public Object Clone()
 {
     Column c = new Column();
     foreach (string s in this._properties.Keys)
     {
         c.Properties[s] = _properties[s];
     }
     return c;
 }