/// <summary> /// construct a Referential constraint /// </summary> /// <param name="relationship"> </param> public ReferentialConstraint(Relationship relationship) : base(relationship) { }
// <summary> // Handler for the Association element // </summary> // <param name="reader"> xml reader currently positioned at Association element </param> private void HandleAssociationElement(XmlReader reader) { DebugCheck.NotNull(reader); var relationship = new Relationship(this, RelationshipKind.Association); relationship.Parse(reader); TryAddType(relationship, true /*doNotAddErrorForEmptyName*/); }
/// <summary> /// construct a Relationship End /// </summary> public RelationshipEnd(Relationship relationship) : base(relationship) { }
private static AssociationType ConvertToAssociationType( Relationship element, DbProviderManifest providerManifest, ConversionCache convertedItemCache, Dictionary<SchemaElement, GlobalItem> newGlobalItems) { Debug.Assert(element.RelationshipKind == RelationshipKind.Association); var associationType = new AssociationType( element.Name, element.Namespace, element.IsForeignKey, GetDataSpace(providerManifest)); newGlobalItems.Add(element, associationType); foreach (RelationshipEnd end in element.Ends) { SchemaType entityTypeElement = end.Type; var endEntityType = (EntityType)LoadSchemaElement( entityTypeElement, providerManifest, convertedItemCache, newGlobalItems); var endMember = InitializeAssociationEndMember(associationType, end, endEntityType); AddOtherContent(end, endMember); // Loop through and convert the operations foreach (var operation in end.Operations) { // Process only the ones that we recognize if (operation.Operation != Operation.Delete) { continue; } // Determine the action for this operation var action = OperationAction.None; switch (operation.Action) { case Action.Cascade: action = OperationAction.Cascade; break; case Action.None: action = OperationAction.None; break; default: Debug.Fail("Operation action not supported."); break; } endMember.DeleteBehavior = action; } // Extract optional Documentation from the end element if (end.Documentation != null) { endMember.Documentation = ConvertToDocumentation(end.Documentation); } } Debug.Assert(associationType.ReferentialConstraints.Count == 0, "This must never have been initialized"); for (var i = 0; i < element.Constraints.Count; i++) { var constraint = element.Constraints[i]; var fromMember = (AssociationEndMember)associationType.Members[constraint.PrincipalRole.Name]; var toMember = (AssociationEndMember)associationType.Members[constraint.DependentRole.Name]; var fromEntityType = ((RefType)fromMember.TypeUsage.EdmType).ElementType; var toEntityType = ((RefType)toMember.TypeUsage.EdmType).ElementType; var referentialConstraint = new ReferentialConstraint( fromMember, toMember, GetProperties(fromEntityType, constraint.PrincipalRole.RoleProperties), GetProperties(toEntityType, constraint.DependentRole.RoleProperties)); // Attach the optional Documentation if (constraint.Documentation != null) { referentialConstraint.Documentation = ConvertToDocumentation(constraint.Documentation); } if (constraint.PrincipalRole.Documentation != null) { referentialConstraint.FromRole.Documentation = ConvertToDocumentation(constraint.PrincipalRole.Documentation); } if (constraint.DependentRole.Documentation != null) { referentialConstraint.ToRole.Documentation = ConvertToDocumentation(constraint.DependentRole.Documentation); } associationType.AddReferentialConstraint(referentialConstraint); AddOtherContent(element.Constraints[i], referentialConstraint); } // Extract the optional Documentation if (element.Documentation != null) { associationType.Documentation = ConvertToDocumentation(element.Documentation); } AddOtherContent(element, associationType); return associationType; }
/// <summary> /// construct a Referential constraint /// </summary> public ReferentialConstraint(Relationship relationship) : base(relationship) { }
// <summary> // construct a Relationship End // </summary> public RelationshipEnd(Relationship relationship) : base(relationship) { }