System.Data.ForeignKeyConstraint.FindParentRelation C# (CSharp) Метод

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

private FindParentRelation ( ) : DataRelation
Результат DataRelation
        internal DataRelation FindParentRelation()
        {
            DataRelationCollection rels = Table.ParentRelations;

            for (int i = 0; i < rels.Count; i++)
            {
                if (rels[i].ChildKeyConstraint == this)
                {
                    return rels[i];
                }
            }
            return null;
        }

Usage Example

Пример #1
0
        internal static  bool AutoGenerated(ForeignKeyConstraint fk, bool checkRelation) {
            // for now we use just this simple logic for the columns.
            DataRelation rel = fk.FindParentRelation();
            if (checkRelation) {
                if (rel == null)
                     return false; // otherwise roundtrip will create column

		if (!AutoGenerated(rel))
                    return false;

                if (rel.RelationName != fk.ConstraintName)
                    return false;
            }

            if (fk.ExtendedProperties.Count > 0)
                return false;


            if (fk.AcceptRejectRule != AcceptRejectRule.None)
                return false;
            if (fk.DeleteRule != Rule.Cascade)
                return false;
            if (fk.DeleteRule != Rule.Cascade)
                return false;


            if (fk.RelatedColumnsReference.Length !=1)
                return false;
            return AutoGenerated(fk.RelatedColumnsReference[0]);
        }
All Usage Examples Of System.Data.ForeignKeyConstraint::FindParentRelation