NavigationProperty

Namespace: EntityFramework
We found 10 examples in language CSharp for this search. You will see 33 fragments of code.

        internal static IEnumerable<string> GetDependentPropertyNames(NavigationProperty navigationProperty) {
            return GetDependentPropertyNames(navigationProperty, true /*checkRelationshipType*/);
        }


        internal static IEnumerable<string> GetDependentPropertyNames(NavigationProperty navigationProperty) {
            return GetDependentPropertyNames(navigationProperty, true /*checkRelationshipType*/);
        }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AbstraX.ServerInterfaces;
using System.Diagnostics;
using AbstraX.AssemblyInterfaces;

namespace AbstraX
{
    [DebuggerDisplay(" { DebugInfo } ")]
    public class NavigationItem
    {
        public object NavigationProperty { get; set; }
        public IElement NavigationResultElement { get; }
        public BaseType PropertyType { get; set; }

        public NavigationItem(IElement navigationProperty, IElement navigationResultElement, BaseType propertyType)
        {
            this.NavigationProperty = navigationProperty;
            this.NavigationResultElement = navigationResultElement;
            this.PropertyType = propertyType;
        }

        public NavigationItem(string navigationPropertyName, IElement navigationResultElement, BaseType propertyType)
        {
            this.NavigationProperty = navigationPropertyName;
            this.NavigationResultElement = navigationResultElement;
            this.PropertyType = propertyType;
        }

        public string PropertyName
        {
            get
            {
                if (this.NavigationProperty is string)
                {
                    return (string)(object) this.NavigationProperty;
                }
                else
                {
                    var element = (IElement)this.NavigationProperty;

                    return element is IGetSetProperty ? ((IGetSetProperty)element).PropertyName : element.Name;
                }
            }
        }

        public bool IsLocal
        {
            get
            {
                if (this.NavigationProperty is string)
                {
                    if (NavigationResultElement is ISurrogateElement)
                    {
                        var surrogate = (ISurrogateElement)NavigationResultElement;

                        return surrogate.ReferencedFrom.Parent.Modifiers.HasFlag(Modifiers.IsLocal);
                    }
                    else
                    {
                        return NavigationResultElement.Parent.Modifiers.HasFlag(Modifiers.IsLocal);
                    }
                }
                else
                {
                    var element = (IElement)this.NavigationProperty;

                    if (element is ISurrogateElement)
                    {
                        var surrogate = (ISurrogateElement)element;

                        return surrogate.ReferencedFrom.Parent.IsLocal();
                    }
                    else
                    {
                        return element.IsLocal();
                    }
                }
            }
        }

        public bool CanRead
        {
            get
            {
                if (this.NavigationProperty is string)
                {
                    return NavigationResultElement.Parent.Modifiers.HasFlag(Modifiers.CanRead);
                }
                else
                {
                    var element = (IElement)this.NavigationProperty;

                    return element.Modifiers.HasFlag(Modifiers.CanRead);
                }
            }
        }

        public bool CanWrite
        {
            get
            {
                if (this.NavigationProperty is string)
                {
                    return NavigationResultElement.Parent.Modifiers.HasFlag(Modifiers.CanWrite);
                }
                else
                {
                    var element = (IElement)this.NavigationProperty;

                    return element.Modifiers.HasFlag(Modifiers.CanWrite);
                }
            }
        }

        public string DebugInfo
        {
            get
            {
                var builder = new StringBuilder();

                if (this.PropertyType != null)
                {
                    builder.AppendFormat("Property: '{0}' returns type: '{1}'", this.PropertyName, this.PropertyType.FullyQualifiedName);
                }
                else
                {
                    builder.AppendFormat("Property: '{0}' returns type: '{1}'", this.PropertyName, "unknown");
                }

                return builder.ToString();
            }
        }
    }
}


        [Fact]
        public void Ctor_MultiplicityProperty_IsInitializedProperly()
        {
            NavigationPropertyConfiguration navigationProperty = new NavigationPropertyConfiguration(new MockPropertyInfo(), EdmMultiplicity.ZeroOrOne, new EntityTypeConfiguration());

            Assert.Equal(EdmMultiplicity.ZeroOrOne, navigationProperty.Multiplicity);
        }

        [Fact]
        public void Property_DeclaringEntityType_Returns_DeclaredType()
        {
            Mock<EntityTypeConfiguration> mockDeclaringType = new Mock<EntityTypeConfiguration>();
            NavigationPropertyConfiguration navigationProperty = new NavigationPropertyConfiguration(new MockPropertyInfo(), EdmMultiplicity.One, mockDeclaringType.Object);

            Assert.Equal(mockDeclaringType.Object, navigationProperty.DeclaringEntityType);
        }

        [Fact]
        public void Optional_ModifiesMultiplicityToZeroOrOne()
        {
            NavigationPropertyConfiguration navigationProperty = new NavigationPropertyConfiguration(new MockPropertyInfo(), EdmMultiplicity.One, new EntityTypeConfiguration());

            navigationProperty.Optional();

            Assert.Equal(EdmMultiplicity.ZeroOrOne, navigationProperty.Multiplicity);
        }

        [Fact]
        public void Required_ModifiesMultiplicityToOne()
        {
            NavigationPropertyConfiguration navigationProperty = new NavigationPropertyConfiguration(new MockPropertyInfo(), EdmMultiplicity.ZeroOrOne, new EntityTypeConfiguration());

            navigationProperty.Required();

            Assert.Equal(EdmMultiplicity.One, navigationProperty.Multiplicity);
        }

        [Fact]
        public void ContainsTarget_DefaultsToFalse()
        {
            // Arrange & Act
            NavigationPropertyConfiguration navigationProperty =
                new NavigationPropertyConfiguration(
                    new MockPropertyInfo(),
                    EdmMultiplicity.ZeroOrOne,
                    new EntityTypeConfiguration());

            // Assert
            Assert.False(navigationProperty.ContainsTarget);
        }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace CodeInterfaces
{
    [DebuggerDisplay(" { DebugInfo } ")]
    public class NavigationItem
    {
        public object NavigationProperty { get; set; }
        public IElement NavigationResultElement { get; private set; }
        public IElementBuild NavigationResultBuild { get; set; }
        public BaseType PropertyType { get; set; }

        public NavigationItem(IElement navigationProperty, IElement navigationResultElement, BaseType propertyType)
        {
            this.NavigationProperty = navigationProperty;
            this.NavigationResultElement = navigationResultElement;
            this.PropertyType = propertyType;
        }

        public NavigationItem(string navigationPropertyName, IElement navigationResultElement, BaseType propertyType)
        {
            this.NavigationProperty = navigationPropertyName;
            this.NavigationResultElement = navigationResultElement;
            this.PropertyType = propertyType;
        }

        public string PropertyName
        {
            get
            {
                if (this.NavigationProperty is string)
                {
                    return (string)(object) this.NavigationProperty;
                }
                else
                {
                    var element = (IElement)this.NavigationProperty;

                    return element is IGetSetProperty ? ((IGetSetProperty) element).PropertyName : element.Name;
                }
            }
        }

        public bool IsLocal
        {
            get
            {
                if (this.NavigationProperty is string)
                {
                    if (NavigationResultElement is ISurrogateElement)
                    {
                        var surrogate = (ISurrogateElement)NavigationResultElement;

                        return surrogate.ReferencedFrom.Parent.Modifiers.HasFlag(Modifiers.IsLocal);
                    }
                    else
                    {
                        return NavigationResultElement.Parent.Modifiers.HasFlag(Modifiers.IsLocal);
                    }
                }
                else
                {
                    var element = (IElement)this.NavigationProperty;

                    if (element is ISurrogateElement)
                    {
                        var surrogate = (ISurrogateElement)element;

                        return surrogate.ReferencedFrom.Parent.IsLocal();
                    }
                    else
                    {
                        return element.IsLocal();
                    }
                }
            }
        }

        public bool CanRead
        {
            get
            {
                if (this.NavigationProperty is string)
                {
                    return NavigationResultElement.Parent.Modifiers.HasFlag(Modifiers.CanRead);
                }
                else
                {
                    var element = (IElement)this.NavigationProperty;

                    return element.Modifiers.HasFlag(Modifiers.CanRead);
                }
            }
        }

        public bool CanWrite
        {
            get
            {
                if (this.NavigationProperty is string)
                {
                    return NavigationResultElement.Parent.Modifiers.HasFlag(Modifiers.CanWrite);
                }
                else
                {
                    var element = (IElement)this.NavigationProperty;

                    return element.Modifiers.HasFlag(Modifiers.CanWrite);
                }
            }
        }

        public string DebugInfo
        {
            get
            {
                var builder = new StringBuilder();

                if (this.NavigationResultBuild != null)
                {
                    builder.AppendFormat("Property: '{0}' returns type: '{1}'", this.PropertyName, this.NavigationResultBuild.Element.DataType.FullyQualifiedName);
                }
                else if (this.PropertyType != null)
                {
                    builder.AppendFormat("Property: '{0}' returns type: '{1}'", this.PropertyName, this.PropertyType.FullyQualifiedName);
                }
                else
                {
                    builder.AppendFormat("Property: '{0}' returns type: '{1}'", this.PropertyName, "unknown");
                }

                return builder.ToString();
            }
        }
    }
}


        internal static IEnumerable<string> GetDependentPropertyNames(NavigationProperty navigationProperty) {
            return GetDependentPropertyNames(navigationProperty, true /*checkRelationshipType*/);
        }

        [Fact]
        public void Apply_is_noop_when_existing_constraint()
        {
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);
            associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
            associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));

            var property = EdmProperty.CreatePrimitive("Fk", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            var associationConstraint
                = new ReferentialConstraint(
                    associationType.SourceEnd,
                    associationType.TargetEnd,
                    new[] { property },
                    new[] { property });

            associationType.Constraint = associationConstraint;

            var navigationProperty = new NavigationProperty("N", TypeUsage.Create(new EntityType("E", "N", DataSpace.CSpace)))
                                         {
                                             RelationshipType = associationType
                                         };

            (new ForeignKeyNavigationPropertyAttributeConvention())
                .Apply(navigationProperty, new DbModel(new EdmModel(DataSpace.CSpace), null));

            Assert.Same(associationConstraint, navigationProperty.Association.Constraint);
        }

        [Fact]
        public void Apply_is_noop_when_no_fk_annotation()
        {
            var navigationProperty = new NavigationProperty("N", TypeUsage.Create(new EntityType("E", "N", DataSpace.CSpace)))
                                         {
                                             RelationshipType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)
                                         };

            (new ForeignKeyNavigationPropertyAttributeConvention())
                .Apply(navigationProperty, new DbModel(new EdmModel(DataSpace.CSpace), null));

            Assert.Null(navigationProperty.Association.Constraint);
        }

        [Fact]
        public void Apply_is_noop_when_unknown_dependent()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);
            associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
            associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));
            var navigationProperty = new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType()))
                                         {
                                             RelationshipType = associationType
                                         };
            var foreignKeyAnnotation = new ForeignKeyAttribute("AId");
            navigationProperty.GetMetadataProperties().SetClrAttributes(new[] { foreignKeyAnnotation });

            (new ForeignKeyNavigationPropertyAttributeConvention())
                .Apply(navigationProperty, new DbModel(model, null));

            Assert.Null(associationType.Constraint);
        }

        [Fact]
        public void Apply_generates_constraint_when_simple_fk()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var entityType = model.AddEntityType("E");
            var associationType = model.AddAssociationType(
                "A",
                entityType, RelationshipMultiplicity.ZeroOrOne,
                entityType, RelationshipMultiplicity.Many);
            var navigationProperty = entityType.AddNavigationProperty("N", associationType);
            var property = EdmProperty.CreatePrimitive("Fk", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property);
            var fkProperty = property;
            var foreignKeyAnnotation = new ForeignKeyAttribute("Fk");
            navigationProperty.GetMetadataProperties().SetClrAttributes(new[] { foreignKeyAnnotation });

            (new ForeignKeyNavigationPropertyAttributeConvention())
                .Apply(navigationProperty, new DbModel(model, null));

            Assert.NotNull(associationType.Constraint);
            Assert.True(associationType.Constraint.ToProperties.Contains(fkProperty));
        }

        [Fact]
        public void Apply_generates_constraint_when_composite_fk()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var entityType = model.AddEntityType("E");
            var associationType = model.AddAssociationType(
                "A",
                entityType, RelationshipMultiplicity.ZeroOrOne,
                entityType, RelationshipMultiplicity.Many);
            var navigationProperty = entityType.AddNavigationProperty("N", associationType);
            var property = EdmProperty.CreatePrimitive("Fk1", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property);
            var fkProperty1 = property;
            var property1 = EdmProperty.CreatePrimitive("Fk2", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            entityType.AddMember(property1);
            var fkProperty2 = property1;
            var foreignKeyAnnotation = new ForeignKeyAttribute("Fk2,Fk1");
            navigationProperty.GetMetadataProperties().SetClrAttributes(new[] { foreignKeyAnnotation });

            (new ForeignKeyNavigationPropertyAttributeConvention())
                .Apply(navigationProperty, new DbModel(model, null));

            Assert.NotNull(associationType.Constraint);
            Assert.True(new[] { fkProperty2, fkProperty1 }.SequenceEqual(associationType.Constraint.ToProperties));
        }

        [Fact]
        public void Apply_throws_when_cannot_find_foreign_key_properties()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var entityType = model.AddEntityType("E");
            var mockType = new MockType();

            entityType.GetMetadataProperties().SetClrType(mockType);
            var associationType = model.AddAssociationType(
                "A",
                entityType, RelationshipMultiplicity.ZeroOrOne,
                entityType, RelationshipMultiplicity.Many);
            var navigationProperty = entityType.AddNavigationProperty("N", associationType);
            var foreignKeyAnnotation = new ForeignKeyAttribute("_Fk");
            navigationProperty.GetMetadataProperties().SetClrAttributes(new[] { foreignKeyAnnotation });

            Assert.Equal(
                Strings.ForeignKeyAttributeConvention_InvalidKey("N", mockType.Object, "_Fk", mockType.Object),
                Assert.Throws<InvalidOperationException>(
                    () => (new ForeignKeyNavigationPropertyAttributeConvention())
                              .Apply(navigationProperty, new DbModel(model, null))).Message);
        }


        private static bool IsZeroOrOne(NavigationProperty navigationProperty) {
            return (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.ZeroOrOne &&
                                navigationProperty.FromEndMember.RelationshipMultiplicity == RelationshipMultiplicity.One) ||
                                (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.One &&
                                navigationProperty.FromEndMember.RelationshipMultiplicity == RelationshipMultiplicity.ZeroOrOne);
        }

        internal static long BuildRelationshipKey(EntityType entityType, RelationshipEndMember member) {
            return Misc.CombineHashCodes(entityType.GetHashCode(), member.GetHashCode());
        }

        internal static IEnumerable<string> GetDependentPropertyNames(NavigationProperty navigationProperty) {
            return GetDependentPropertyNames(navigationProperty, true /*checkRelationshipType*/);
        }

        internal static IEnumerable<string> GetDependentPropertyNames(NavigationProperty navigationProperty, bool checkRelationshipType) {
            if (checkRelationshipType) {
                if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.ZeroOrOne &&
                    navigationProperty.FromEndMember.RelationshipMultiplicity == RelationshipMultiplicity.One) {
                    // Get constraint when this association is on the "parent" (aka "from") side. This means
                    // that the navProperty represents a Children association in a 1-1 relationship. For example,
                    // this could be a Item-ItemDetail scenario where the ItemDetail table has a PK that is also an FK
                    // into the Item table (thus ensuring the 1-1 cardinality). We need to special case this situation because normally we would try
                    // to build a foreign key name of the form "Item.ItemID", but we want just "ItemID".
                    AssociationType relationshipType = (AssociationType)navigationProperty.RelationshipType;
                    ReferentialConstraint constraint = relationshipType.ReferentialConstraints.FirstOrDefault(c => c.ToRole == navigationProperty.ToEndMember);
                    if (constraint != null) {
                        return constraint.FromProperties.Select(p => p.Name);
                    }

                    // Fall back on the primary keys if no constraints were found but only if we are on the parent side. i.e the 1 side Item side in an Item-ItemDetail
                    // Get the primary keys on the "from" side of the relationship. i.e Product.Category -> ProductID
                    return navigationProperty.FromEndMember.GetEntityType().KeyMembers.Select(m => m.Name);
                }
            }
            return navigationProperty.GetDependentProperties().Select(m => m.Name);
        }

        public override string GetSortExpression(ColumnProvider sortColumn) {
            return GetSortExpression(sortColumn, "{0}.{1}");
        }


        /// <summary>
        /// Marks this entity type as abstract.
        /// </summary>
        /// <returns>Returns itself so that multiple calls can be chained.</returns>
        public virtual EntityTypeConfiguration Abstract()
        {
            AbstractImpl();
            return this;
        }

        /// <summary>
        /// Configures the key property(s) for this entity type.
        /// </summary>
        /// <param name="keyProperty">The property to be added to the key properties of this entity type.</param>
        /// <returns>Returns itself so that multiple calls can be chained.</returns>
        public virtual EntityTypeConfiguration HasKey(PropertyInfo keyProperty)
        {
            if (BaseType != null)
            {
                throw Error.InvalidOperation(SRResources.CannotDefineKeysOnDerivedTypes, FullName, BaseType.FullName);
            }

            PrimitivePropertyConfiguration propertyConfig = AddProperty(keyProperty);

            // keys are always required
            propertyConfig.IsRequired();

            if (!_keys.Contains(propertyConfig))
            {
                _keys.Add(propertyConfig);
            }

            return this;
        }

        /// <summary>
        /// Removes the property from the entity keys collection.
        /// </summary>
        /// <param name="keyProperty">The key to be removed.</param>
        /// <remarks>This method just disable the property to be not a key anymore. It does not remove the property all together.
        /// To remove the property completely, use the method <see cref="RemoveProperty"/></remarks>
        public virtual void RemoveKey(PrimitivePropertyConfiguration keyProperty)
        {
            if (keyProperty == null)
            {
                throw Error.ArgumentNull("keyProperty");
            }

            _keys.Remove(keyProperty);
        }

        /// <summary>
        /// Sets the base type of this entity type to <c>null</c> meaning that this entity type 
        /// does not derive from anything.
        /// </summary>
        /// <returns>Returns itself so that multiple calls can be chained.</returns>
        public virtual EntityTypeConfiguration DerivesFromNothing()
        {
            DerivesFromNothingImpl();
            return this;
        }

        /// <summary>
        /// Sets the base type of this entity type.
        /// </summary>
        /// <param name="baseType">The base entity type.</param>
        /// <returns>Returns itself so that multiple calls can be chained.</returns>
        public virtual EntityTypeConfiguration DerivesFrom(EntityTypeConfiguration baseType)
        {
            if (Keys.Any())
            {
                throw Error.InvalidOperation(SRResources.CannotDefineKeysOnDerivedTypes, FullName, baseType.FullName);
            }

            DerivesFromImpl(baseType);
            return this;
        }

        /// <summary>
        /// Adds a non-contained EDM navigation property to this entity type.
        /// </summary>
        /// <param name="navigationProperty">The backing CLR property.</param>
        /// <param name="multiplicity">The <see cref="EdmMultiplicity"/> of the navigation property.</param>
        /// <returns>Returns the <see cref="NavigationPropertyConfiguration"/> of the added property.</returns>
        public virtual NavigationPropertyConfiguration AddNavigationProperty(PropertyInfo navigationProperty, EdmMultiplicity multiplicity)
        {
            return AddNavigationProperty(navigationProperty, multiplicity, containsTarget: false);
        }


        /// <summary>
        /// Creates a navigation link info for a deferred link.
        /// </summary>
        /// <param name="navigationLink">The navigation link to report.</param>
        /// <param name="navigationProperty">The navigation property for which the link will be reported.</param>
        /// <returns>The navigation link info created.</returns>
        internal static ODataJsonLightReaderNavigationLinkInfo CreateDeferredLinkInfo(
            ODataNavigationLink navigationLink,
            IEdmNavigationProperty navigationProperty)
        {
            return new ODataJsonLightReaderNavigationLinkInfo(navigationLink, navigationProperty, /*isExpanded*/ false);
        }

        /// <summary>
        /// Creates a navigation link info for an expanded entry link.
        /// </summary>
        /// <param name="navigationLink">The navigation link to report.</param>
        /// <param name="navigationProperty">The navigation property for which the link will be reported.</param>
        /// <returns>The navigation link info created.</returns>
        internal static ODataJsonLightReaderNavigationLinkInfo CreateExpandedEntryLinkInfo(
            ODataNavigationLink navigationLink,
            IEdmNavigationProperty navigationProperty)
        {
            Debug.Assert(navigationLink != null, "navigationLink != null");
            Debug.Assert(navigationLink.IsCollection == false, "Expanded entry can only be reported for a singleton navigation link.");

            ODataJsonLightReaderNavigationLinkInfo navigationLinkInfo = new ODataJsonLightReaderNavigationLinkInfo(navigationLink, navigationProperty, /*isExpanded*/ true);
            return navigationLinkInfo;
        }

        /// <summary>
        /// Creates a navigation link info for an expanded feed link.
        /// </summary>
        /// <param name="navigationLink">The navigation link to report.</param>
        /// <param name="navigationProperty">The navigation property for which the link will be reported.</param>
        /// <param name="expandedFeed">The expanded feed for the navigation link to report.</param>
        /// <returns>The navigation link info created.</returns>
        internal static ODataJsonLightReaderNavigationLinkInfo CreateExpandedFeedLinkInfo(
            ODataNavigationLink navigationLink,
            IEdmNavigationProperty navigationProperty,
            ODataFeed expandedFeed)
        {
            Debug.Assert(navigationLink != null, "navigationLink != null");
            Debug.Assert(navigationLink.IsCollection == true, "Expanded feeds can only be reported for collection navigation links.");
            Debug.Assert(expandedFeed != null, "expandedFeed != null");

            ODataJsonLightReaderNavigationLinkInfo navigationLinkInfo = new ODataJsonLightReaderNavigationLinkInfo(navigationLink, navigationProperty, /*isExpanded*/ true);
            navigationLinkInfo.expandedFeed = expandedFeed;
            return navigationLinkInfo;
        }

        /// <summary>
        /// Creates a navigation link info for a singleton entity reference link.
        /// </summary>
        /// <param name="navigationLink">The navigation link to report.</param>
        /// <param name="navigationProperty">The navigation property for which the link will be reported.</param>
        /// <param name="entityReferenceLink">The entity reference link for the navigation link to report.</param>
        /// <param name="isExpanded">true if the navigation link is expanded.</param>
        /// <returns>The navigation link info created.</returns>
        internal static ODataJsonLightReaderNavigationLinkInfo CreateSingletonEntityReferenceLinkInfo(
            ODataNavigationLink navigationLink,
            IEdmNavigationProperty navigationProperty,
            ODataEntityReferenceLink entityReferenceLink,
            bool isExpanded)
        {
            Debug.Assert(navigationLink != null, "navigationLink != null");
            Debug.Assert(navigationLink.IsCollection == false, "Singleton entity reference can only be reported for a singleton navigation links.");
            Debug.Assert(navigationProperty != null, "navigationProperty != null");

            ODataJsonLightReaderNavigationLinkInfo navigationLinkInfo = new ODataJsonLightReaderNavigationLinkInfo(navigationLink, navigationProperty, isExpanded);
            if (entityReferenceLink != null)
            {
                navigationLinkInfo.entityReferenceLinks = new LinkedList<ODataEntityReferenceLink>();
                navigationLinkInfo.entityReferenceLinks.AddFirst(entityReferenceLink);
            }

            return navigationLinkInfo;
        }

        /// <summary>
        /// Creates a navigation link info for a collection of entity reference links.
        /// </summary>
        /// <param name="navigationLink">The navigation link to report.</param>
        /// <param name="navigationProperty">The navigation property for which the link will be reported.</param>
        /// <param name="entityReferenceLinks">The entity reference links for the navigation link to report.</param>
        /// <param name="isExpanded">true if the navigation link is expanded.</param>
        /// <returns>The navigation link info created.</returns>
        internal static ODataJsonLightReaderNavigationLinkInfo CreateCollectionEntityReferenceLinksInfo(
            ODataNavigationLink navigationLink,
            IEdmNavigationProperty navigationProperty,
            LinkedList<ODataEntityReferenceLink> entityReferenceLinks,
            bool isExpanded)
        {
            Debug.Assert(navigationLink != null, "navigationLink != null");
            Debug.Assert(navigationLink.IsCollection == true, "Collection entity reference can only be reported for a collection navigation links.");
            Debug.Assert(navigationProperty != null, "navigationProperty != null");
            Debug.Assert(entityReferenceLinks == null || entityReferenceLinks.Count > 0, "entityReferenceLinks == null || entityReferenceLinks.Count > 0");

            ODataJsonLightReaderNavigationLinkInfo navigationLinkInfo = new ODataJsonLightReaderNavigationLinkInfo(navigationLink, navigationProperty, isExpanded);
            navigationLinkInfo.entityReferenceLinks = entityReferenceLinks;
            return navigationLinkInfo;
        }

        /// <summary>
        /// Creates a navigation link info for a projected navigation link that is missing from the payload.
        /// </summary>
        /// <param name="navigationProperty">The navigation property for which the link will be reported.</param>
        /// <returns>The navigation link info created.</returns>
        internal static ODataJsonLightReaderNavigationLinkInfo CreateProjectedNavigationLinkInfo(IEdmNavigationProperty navigationProperty)
        {
            Debug.Assert(navigationProperty != null, "navigationProperty != null");

            ODataNavigationLink navigationLink = new ODataNavigationLink { Name = navigationProperty.Name, IsCollection = navigationProperty.Type.IsCollection() };
            ODataJsonLightReaderNavigationLinkInfo navigationLinkInfo = new ODataJsonLightReaderNavigationLinkInfo(navigationLink, navigationProperty, /*isExpanded*/ false);
            return navigationLinkInfo;
        }

Methods :

public BuiltInTypeKind get_BuiltInTypeKind()
public RelationshipType get_RelationshipType()
public RelationshipEndMember get_ToEndMember()
public RelationshipEndMember get_FromEndMember()
public IEnumerable<EdmProperty> GetDependentProperties()
public static NavigationProperty Create(String name = , TypeUsage typeUsage = , RelationshipType relationshipType = , RelationshipEndMember from = , RelationshipEndMember to = , IEnumerable<MetadataProperty> metadataProperties = )
public String get_Name()
public Void set_Name(String value = )
public StructuralType get_DeclaringType()
public TypeUsage get_TypeUsage()
public String ToString()
public Boolean get_IsStoreGeneratedComputed()
public Boolean get_IsStoreGeneratedIdentity()
public ReadOnlyMetadataCollection<MetadataProperty> get_MetadataProperties()
public Void AddAnnotation(String name = , Object value = )
public Boolean RemoveAnnotation(String name = )
public Documentation get_Documentation()
public Void set_Documentation(Documentation value = )
public Type GetType()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()