コード例 #1
0
        // <summary>
        // Is this relationship a binary relationship (ie) does it have exactly 2 end points?
        // This should ideally be a method supported by RelationType itself
        // </summary>
        // <returns> true, if this is a binary relationship </returns>
        private static bool IsBinary(md.RelationshipType relationshipType)
        {
            var endCount = 0;

            foreach (var member in relationshipType.Members)
            {
                if (member is md.RelationshipEndMember)
                {
                    endCount++;
                    if (endCount > 2)
                    {
                        return(false);
                    }
                }
            }
            return(endCount == 2);
        }
コード例 #2
0
        // <summary>
        // Add any rel properties that are induced by the supplied relationship
        // </summary>
        // <param name="relationshipType"> the relationship </param>
        private void ProcessRelationship(RelationshipType relationshipType)
        {
            var associationType = relationshipType as AssociationType;
            if (associationType == null)
            {
                return;
            }

            // Handle only binary associations
            if (associationType.AssociationEndMembers.Count != 2)
            {
                return;
            }

            var end0 = associationType.AssociationEndMembers[0];
            var end1 = associationType.AssociationEndMembers[1];

            AddRelProperty(associationType, end0, end1);
            AddRelProperty(associationType, end1, end0);
        }
コード例 #3
0
        /// <summary>
        /// Creates a NavigationProperty instance from the specified parameters.
        /// </summary>
        /// <param name="name">The name of the navigation property.</param>
        /// <param name="typeUsage">Specifies the navigation property type and its facets.</param>
        /// <param name="relationshipType">The relationship type for the navigation.</param>
        /// <param name="from">The source end member in the navigation.</param>
        /// <param name="to">The target end member in the navigation.</param>
        /// <param name="metadataProperties">The metadata properties of the navigation property.</param>
        /// <returns>The newly created NavigationProperty instance.</returns>
        public static NavigationProperty Create(
            string name,
            TypeUsage typeUsage,
            RelationshipType relationshipType,
            RelationshipEndMember from,
            RelationshipEndMember to,
            IEnumerable<MetadataProperty> metadataProperties)
        {
            Check.NotEmpty(name, "name");
            Check.NotNull(typeUsage, "typeUsage");

            var instance = new NavigationProperty(name, typeUsage);

            instance.RelationshipType = relationshipType;
            instance.FromEndMember = from;
            instance.ToEndMember = to;

            if (metadataProperties != null)
            {
                instance.AddMetadataProperties(metadataProperties.ToList());
            }

            instance.SetReadOnly();

            return instance;
        }
コード例 #4
0
 internal RelProperty(RelationshipType relationshipType, RelationshipEndMember fromEnd, RelationshipEndMember toEnd)
 {
     m_relationshipType = relationshipType;
     m_fromEnd = fromEnd;
     m_toEnd = toEnd;
 }
コード例 #5
0
        protected virtual void Visit(RelationshipType relationshipType)
        {
            // switching node, will not be add to the seen list
            if (relationshipType == null)
            {
                return;
            }

            #region Inner data visit

            switch (relationshipType.BuiltInTypeKind)
            {
                case BuiltInTypeKind.AssociationType:
                    Visit((AssociationType)relationshipType);
                    break;
                default:
                    Debug.Fail(
                        String.Format(
                            CultureInfo.InvariantCulture, "Found type '{0}', did we add a new type?", relationshipType.BuiltInTypeKind));
                    break;
            }

            #endregion
        }
コード例 #6
0
 /// <summary>
 /// Get the list of relationshipsets that can hold instances of the given relationshiptype
 /// 
 /// We identify the list of relationshipsets in the current list of entitycontainers that are 
 /// of the given type. Since we don't yet support relationshiptype subtyping, this is a little
 /// easier than the entity version
 /// </summary>
 /// <param name="relType">the relationship type to look for</param>
 /// <returns>the list of relevant relationshipsets</returns>
 private List<RelationshipSet> GetRelationshipSets(RelationshipType relType)
 {
     var relSets = new List<RelationshipSet>();
     foreach (var entityContainer in m_referencedEntityContainers)
     {
         foreach (var set in entityContainer.BaseEntitySets)
         {
             var relSet = set as RelationshipSet;
             if (relSet != null
                 &&
                 relSet.ElementType.Equals(relType))
             {
                 relSets.Add(relSet);
             }
         }
     }
     return relSets;
 }
コード例 #7
0
 protected override void Visit(RelationshipType relationshipType)
 {
     base.Visit(relationshipType);
 }
コード例 #8
0
 /// <summary>
 ///     Dumps the specified Relation metadata instance
 /// </summary>
 /// <param name="type"> The Relation metadata to dump </param>
 internal void Dump(RelationshipType type)
 {
     Begin(
         "RelationshipType",
         "Namespace", type.NamespaceName,
         "Name",
         type.Name
         );
     End("RelationshipType");
 }
コード例 #9
0
 /// <summary>
 ///     Dumps the specified Relation metadata instance with the specified decoration
 /// </summary>
 /// <param name="type"> The Relation metadata to dump </param>
 /// <param name="name"> The decorating block name </param>
 internal void Dump(RelationshipType type, string name)
 {
     Begin(name);
     Dump(type);
     End(name);
 }
コード例 #10
0
        /// <summary>
        ///     Creates a NavigationProperty instance from the specified parameters.
        /// </summary>
        /// <param name="name">The name of the navigation property.</param>
        /// <param name="typeUsage">Specifies the navigation property type and its facets.</param>
        /// <param name="relationshipType">The relationship type for the navigation.</param>
        /// <param name="from">The source end member in the navigation.</param>
        /// <param name="to">The target end member in the navigation.</param>
        /// <returns>The newly created NavigationProperty instance.</returns>
        public static NavigationProperty Create(
            string name,
            TypeUsage typeUsage,
            RelationshipType relationshipType,
            RelationshipEndMember from,
            RelationshipEndMember to)
        {
            var instance = new NavigationProperty(name, typeUsage);

            instance.RelationshipType = relationshipType;
            instance.FromEndMember = from;
            instance.ToEndMember = to;

            instance.SetReadOnly();

            return instance;
        }