/// <summary> /// Add the association type associated with this set. /// </summary> /// <param name="association">Association type.</param> internal void SetAssociationType(ResourceAssociationType association) { Debug.Assert(association != null, "association != null"); Debug.Assert(this.ResourceAssociationType == null, "this.associationType == null"); this.ResourceAssociationType = association; }
/// <summary> /// Populate the ResourceReferentialConstraint instance from the ReferentialConstraint instance. /// </summary> /// <param name="resourceAssociationType">ResourceAssociationType instance.</param> /// <param name="referentialConstraint">ReferentialConstraint instance.</param> private static void PopulateReferentialConstraint(ResourceAssociationType resourceAssociationType, ReferentialConstraint referentialConstraint) { ResourceAssociationTypeEnd principalEnd = resourceAssociationType.GetEnd(referentialConstraint.FromRole.Name); ResourceAssociationTypeEnd dependentEnd = resourceAssociationType.GetEnd(referentialConstraint.ToRole.Name); List<ResourceProperty> dependentProperties = new List<ResourceProperty>(); foreach (EdmProperty edmProperty in referentialConstraint.ToProperties) { dependentProperties.Add(dependentEnd.ResourceType.TryResolvePropertyName(edmProperty.Name)); } resourceAssociationType.ReferentialConstraint = new ResourceReferentialConstraint(principalEnd, dependentProperties); ObjectContextServiceProvider.PopulateAnnotations(referentialConstraint.MetadataProperties, resourceAssociationType.ReferentialConstraint.AddCustomAnnotation); }
/// <summary> /// Populate the ResourceAssociationType from the AssociationType instance. /// </summary> /// <param name="associationType">AssociationType instance.</param> /// <param name="end1">ResourceAssociationTypeEnd instance.</param> /// <param name="end2">ResourceAssociationTypeEnd instance.</param> /// <returns>An instance of ResourceAssociationType.</returns> private static ResourceAssociationType PopulateResourceAssociationType(AssociationType associationType, ResourceAssociationTypeEnd end1, ResourceAssociationTypeEnd end2) { ResourceAssociationType resourceAssociationType = new ResourceAssociationType( associationType.Name, associationType.NamespaceName, end1, end2); ObjectContextServiceProvider.PopulateAnnotations(associationType.MetadataProperties, resourceAssociationType.AddCustomAnnotation); if (associationType.ReferentialConstraints != null && associationType.ReferentialConstraints.Count != 0) { PopulateReferentialConstraint(resourceAssociationType, associationType.ReferentialConstraints[0]); } return resourceAssociationType; }