internal void ValidateMultipleNestedRelations()
 {
     if ((this.Nested && this.CheckMultipleNested) && (0 < this.ChildTable.NestedParentRelations.Length))
     {
         DataColumn[] childColumns = this.ChildColumns;
         if ((childColumns.Length != 1) || !this.IsAutoGenerated(childColumns[0]))
         {
             throw ExceptionBuilder.TableCantBeNestedInTwoTables(this.ChildTable.TableName);
         }
         if (!XmlTreeGen.AutoGenerated(this))
         {
             throw ExceptionBuilder.TableCantBeNestedInTwoTables(this.ChildTable.TableName);
         }
         foreach (Constraint constraint in this.ChildTable.Constraints)
         {
             if (constraint is ForeignKeyConstraint)
             {
                 ForeignKeyConstraint fk = (ForeignKeyConstraint)constraint;
                 if (!XmlTreeGen.AutoGenerated(fk, true))
                 {
                     throw ExceptionBuilder.TableCantBeNestedInTwoTables(this.ChildTable.TableName);
                 }
             }
             else
             {
                 UniqueConstraint unique = (UniqueConstraint)constraint;
                 if (!XmlTreeGen.AutoGenerated(unique))
                 {
                     throw ExceptionBuilder.TableCantBeNestedInTwoTables(this.ChildTable.TableName);
                 }
             }
         }
     }
 }
예제 #2
0
        private bool AutoGenerated(Constraint constraint)
        {
            ForeignKeyConstraint fk = constraint as ForeignKeyConstraint;

            if (fk != null)
            {
                return(XmlTreeGen.AutoGenerated(fk, false));
            }
            UniqueConstraint unique = (UniqueConstraint)constraint;

            return(XmlTreeGen.AutoGenerated(unique));
        }
예제 #3
0
        private bool AutoGenerated(Constraint constraint)
        {
            ForeignKeyConstraint fk = (constraint as ForeignKeyConstraint);

            if (null != fk)
            {
                return(XmlTreeGen.AutoGenerated(fk, false));
            }
            else
            {
                UniqueConstraint unique = (UniqueConstraint)constraint;
                return(XmlTreeGen.AutoGenerated(unique));
            }
        }
예제 #4
0
        internal void ValidateMultipleNestedRelations()
        {
            // find all nested relations that this child table has
            // if this relation is the only relation it has, then fine,
            // otherwise check if all relations are created from XSD, without using Key/KeyRef
            // check all keys to see autogenerated

            if (!Nested || !CheckMultipleNested) // no need for this verification
            {
                return;
            }

            if (0 < ChildTable.NestedParentRelations.Length)
            {
                DataColumn[] childCols = ChildColumns;
                if (childCols.Length != 1 || !IsAutoGenerated(childCols[0]))
                {
                    throw ExceptionBuilder.TableCantBeNestedInTwoTables(ChildTable.TableName);
                }

                if (!XmlTreeGen.AutoGenerated(this))
                {
                    throw ExceptionBuilder.TableCantBeNestedInTwoTables(ChildTable.TableName);
                }

                foreach (Constraint cs in ChildTable.Constraints)
                {
                    if (cs is ForeignKeyConstraint)
                    {
                        ForeignKeyConstraint fk = (ForeignKeyConstraint)cs;
                        if (!XmlTreeGen.AutoGenerated(fk, true))
                        {
                            throw ExceptionBuilder.TableCantBeNestedInTwoTables(ChildTable.TableName);
                        }
                    }
                    else
                    {
                        UniqueConstraint unique = (UniqueConstraint)cs;
                        if (!XmlTreeGen.AutoGenerated(unique))
                        {
                            throw ExceptionBuilder.TableCantBeNestedInTwoTables(ChildTable.TableName);
                        }
                    }
                }
            }
        }