/// <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); }
/// <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; }