Ejemplo n.º 1
0
        /// <summary>
        /// Returns the LinkInfo for the given navigation property. 
        /// </summary>
        /// <param name="propertyName">name of the navigation property </param>
        /// <param name="linkInfo"> LinkInfo for the navigation propery</param>
        /// <returns>true if LinkInfo is found for the navigation property, false if not found</returns>
        internal bool TryGetLinkInfo(string propertyName, out LinkInfo linkInfo)
        {
            Util.CheckArgumentNullAndEmpty(propertyName, "propertyName");
            Debug.Assert(propertyName.IndexOf('/') == -1, "propertyName.IndexOf('/') == -1");

            linkInfo = null;
            if (this.TransientEntityDescriptor != null && this.TransientEntityDescriptor.TryGetLinkInfo(propertyName, out linkInfo))
            {
                return true;
            }
            else if (this.relatedEntityLinks != null)
            {
                return this.relatedEntityLinks.TryGetValue(propertyName, out linkInfo);
            }

            return false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns LinkInfo for the given property, if it does not exists than a new one is created.
        /// </summary>
        /// <param name="propertyName">name of the navigation property</param>
        /// <returns>LinkInfo for propertyName</returns>
        private LinkInfo GetLinkInfo(String propertyName)
        {
            if (this.relatedEntityLinks == null)
            {
                this.relatedEntityLinks = new Dictionary<string, LinkInfo>(StringComparer.Ordinal);
            }

            LinkInfo linkInfo = null;
            if (!this.relatedEntityLinks.TryGetValue(propertyName, out linkInfo))
            {
                linkInfo = new LinkInfo(propertyName);
                this.relatedEntityLinks[propertyName] = linkInfo;
            }

            return linkInfo;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Merges the given linkInfo to the entity descriptor, 
        /// overwrites existing links with new ones (coming from the payload)
        /// </summary>
        /// <param name="linkInfo">linkInfo</param>
        internal void MergeLinkInfo(LinkInfo linkInfo)
        {
            if (this.relatedEntityLinks == null)
            {
                this.relatedEntityLinks = new Dictionary<string, LinkInfo>(StringComparer.Ordinal);
            }

            LinkInfo existingLinkInfo = null;
            if (!this.relatedEntityLinks.TryGetValue(linkInfo.Name, out existingLinkInfo))
            {
                this.relatedEntityLinks[linkInfo.Name] = linkInfo;
            }
            else
            {
                // overwrite existing links with new ones (coming from the payload).
                if (linkInfo.AssociationLink != null)
                {
                    existingLinkInfo.AssociationLink = linkInfo.AssociationLink;
                }

                if (linkInfo.NavigationLink != null)
                {
                    existingLinkInfo.NavigationLink = linkInfo.NavigationLink;
                }
            }
        }