Пример #1
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,
            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);
        }
Пример #2
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);
        }
        public void Nullability_updated_when_property_goes_readonly()
        {
            var navigationProperty 
                = new NavigationProperty("N", TypeUsage.Create(new EntityType("E", "N", DataSpace.CSpace)))
                                         {
                                             ToEndMember =
                                                 new AssociationEndMember(
                                                 "T", new RefType(new EntityType("E", "N", DataSpace.CSpace)), RelationshipMultiplicity.ZeroOrOne)
                                         };

            Assert.Equal(true, navigationProperty.TypeUsage.Facets[EdmConstants.Nullable].Value);

            navigationProperty.ToEndMember.RelationshipMultiplicity = RelationshipMultiplicity.One;

            Assert.Equal(true, navigationProperty.TypeUsage.Facets[EdmConstants.Nullable].Value);

            navigationProperty.SetReadOnly();

            Assert.Equal(false, navigationProperty.TypeUsage.Facets[EdmConstants.Nullable].Value);
        }
Пример #4
0
        public void Nullability_updated_when_property_goes_readonly()
        {
            var navigationProperty
                = new NavigationProperty("N", TypeUsage.Create(new EntityType("E", "N", DataSpace.CSpace)))
                {
                ToEndMember =
                    new AssociationEndMember(
                        "T", new RefType(new EntityType("E", "N", DataSpace.CSpace)), RelationshipMultiplicity.ZeroOrOne)
                };

            Assert.Equal(true, navigationProperty.TypeUsage.Facets[EdmConstants.Nullable].Value);

            navigationProperty.ToEndMember.RelationshipMultiplicity = RelationshipMultiplicity.One;

            Assert.Equal(true, navigationProperty.TypeUsage.Facets[EdmConstants.Nullable].Value);

            navigationProperty.SetReadOnly();

            Assert.Equal(false, navigationProperty.TypeUsage.Facets[EdmConstants.Nullable].Value);
        }
        /// <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, nameof(name));
            Check.NotNull <TypeUsage>(typeUsage, nameof(typeUsage));
            NavigationProperty navigationProperty = new NavigationProperty(name, typeUsage);

            navigationProperty.RelationshipType = relationshipType;
            navigationProperty.FromEndMember    = from;
            navigationProperty.ToEndMember      = to;
            if (metadataProperties != null)
            {
                navigationProperty.AddMetadataProperties(metadataProperties.ToList <MetadataProperty>());
            }
            navigationProperty.SetReadOnly();
            return(navigationProperty);
        }
        /// <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;
        }
        /// <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;
        }