private void PairUpNavigationPropertiesForEntitySet(MetadataProviderEdmEntityContainer entityContainer, ResourceSetWrapper resourceSet) { foreach (ResourceType type in this.MetadataProvider.GetDerivedTypes(resourceSet.ResourceType)) { this.PairUpNavigationPropertiesForEntitySetAndType(entityContainer, resourceSet, type); } for (ResourceType type2 = resourceSet.ResourceType; type2 != null; type2 = type2.BaseType) { this.PairUpNavigationPropertiesForEntitySetAndType(entityContainer, resourceSet, type2); } }
internal MetadataProviderEdmFunctionImport(MetadataProviderEdmModel model, MetadataProviderEdmEntityContainer container, OperationWrapper operation) { this.container = container; this.model = model; this.operation = operation; if (operation.Kind == OperationKind.Action) { this.isSideEffecting = true; this.isComposable = false; this.isBindable = this.operation.BindingParameter != null; } else { this.isComposable = false; this.isSideEffecting = true; this.isBindable = false; } ResourceSetPathExpression resultSetPathExpression = operation.ResultSetPathExpression; this.entitySetPath = (resultSetPathExpression == null) ? null : resultSetPathExpression.PathExpression; if (operation.Kind == OperationKind.ServiceOperation) { model.SetHttpMethod(this, operation.Method); } string mimeType = operation.MimeType; if (!string.IsNullOrEmpty(mimeType)) { model.SetMimeType(this, mimeType); } if (operation.OperationParameterBindingKind == OperationParameterBindingKind.Always) { model.SetIsAlwaysBindable(this, true); } ReadOnlyCollection <OperationParameter> parameters = operation.Parameters; if ((parameters != null) && (parameters.Count > 0)) { List <IEdmFunctionParameter> list = new List <IEdmFunctionParameter>(parameters.Count); foreach (OperationParameter parameter in parameters) { IEdmTypeReference typeReference = this.model.EnsureTypeReference(parameter.ParameterType, null); if (!typeReference.IsNullable && (this.model.GetEdmVersion() < DataServiceProtocolVersion.V3.ToVersion())) { typeReference = typeReference.Clone(true); } EdmFunctionParameter item = new EdmFunctionParameter(this, parameter.Name, typeReference, EdmFunctionParameterMode.In); list.Add(item); } this.parameters = new ReadOnlyCollection <IEdmFunctionParameter>(list); } }
private void PairUpNavigationPropertiesForEntitySetAndType(MetadataProviderEdmEntityContainer entityContainer, ResourceSetWrapper resourceSet, ResourceType resourceType) { IEnumerable <ResourceProperty> allVisiblePropertiesDeclaredInThisType = this.GetAllVisiblePropertiesDeclaredInThisType(resourceType); if (allVisiblePropertiesDeclaredInThisType != null) { foreach (ResourceProperty property in from p in allVisiblePropertiesDeclaredInThisType where p.TypeKind == ResourceTypeKind.EntityType select p) { this.PairUpNavigationProperty(entityContainer, resourceSet, resourceType, property); } } }
internal MetadataProviderEdmFunctionImport(MetadataProviderEdmModel model, MetadataProviderEdmEntityContainer container, OperationWrapper operation) { this.container = container; this.model = model; this.operation = operation; if (operation.Kind == OperationKind.Action) { this.isSideEffecting = true; this.isComposable = false; this.isBindable = this.operation.BindingParameter != null; } else { this.isComposable = false; this.isSideEffecting = true; this.isBindable = false; } ResourceSetPathExpression resultSetPathExpression = operation.ResultSetPathExpression; this.entitySetPath = (resultSetPathExpression == null) ? null : resultSetPathExpression.PathExpression; if (operation.Kind == OperationKind.ServiceOperation) { model.SetHttpMethod(this, operation.Method); } string mimeType = operation.MimeType; if (!string.IsNullOrEmpty(mimeType)) { model.SetMimeType(this, mimeType); } if (operation.OperationParameterBindingKind == OperationParameterBindingKind.Always) { model.SetIsAlwaysBindable(this, true); } ReadOnlyCollection<OperationParameter> parameters = operation.Parameters; if ((parameters != null) && (parameters.Count > 0)) { List<IEdmFunctionParameter> list = new List<IEdmFunctionParameter>(parameters.Count); foreach (OperationParameter parameter in parameters) { IEdmTypeReference typeReference = this.model.EnsureTypeReference(parameter.ParameterType, null); if (!typeReference.IsNullable && (this.model.GetEdmVersion() < DataServiceProtocolVersion.V3.ToVersion())) { typeReference = typeReference.Clone(true); } EdmFunctionParameter item = new EdmFunctionParameter(this, parameter.Name, typeReference, EdmFunctionParameterMode.In); list.Add(item); } this.parameters = new ReadOnlyCollection<IEdmFunctionParameter>(list); } }
private void PairUpNavigationProperties() { string containerName = this.metadataProvider.ContainerName; IEnumerable <ResourceSetWrapper> resourceSets = this.metadataProvider.GetResourceSets(); if (resourceSets != null) { foreach (ResourceSetWrapper wrapper in resourceSets) { string str2 = wrapper.EntityContainerName ?? containerName; MetadataProviderEdmEntityContainer entityContainer = this.entityContainerCache[str2]; this.PairUpNavigationPropertiesForEntitySet(entityContainer, wrapper); } } }
internal MetadataProviderEdmEntityContainer EnsureDefaultEntityContainer() { MetadataProviderEdmEntityContainer container; string containerName = this.metadataProvider.ContainerName; if (!this.entityContainerCache.TryGetValue(containerName, out container)) { container = new MetadataProviderEdmEntityContainer(this, containerName, this.GetContainerNamespace()); this.SetIsDefaultEntityContainer(container, true); MetadataProviderUtils.ConvertCustomAnnotations(this, this.metadataProvider.GetEntityContainerAnnotations(containerName), container); this.entityContainerCache.Add(containerName, container); this.entityContainerCache.Add(container.FullName(), container); } return(container); }
private void PairUpNavigationProperty(MetadataProviderEdmEntityContainer entityContainer, ResourceSetWrapper resourceSet, ResourceType resourceType, ResourceProperty navigationProperty) { string key = string.Concat(new object[] { resourceSet.Name, '_', resourceType.FullName, '_', navigationProperty.Name }); if (!this.associationSetByKeyCache.ContainsKey(key)) { ResourceAssociationSet resourceAssociationSet = this.MetadataProvider.GetResourceAssociationSet(resourceSet, resourceType, navigationProperty); if (resourceAssociationSet != null) { string str2; string str3; ResourceAssociationSetEnd end = resourceAssociationSet.GetRelatedResourceAssociationSetEnd(resourceSet, resourceType, navigationProperty); if (end.ResourceProperty != null) { ResourceAssociationSet set2 = this.MetadataProvider.GetResourceAssociationSet(this.MetadataProvider.ValidateResourceSet(end.ResourceSet), end.ResourceType, end.ResourceProperty); if ((set2 == null) || (resourceAssociationSet.Name != set2.Name)) { throw new InvalidOperationException(System.Data.Services.Strings.ResourceAssociationSet_BidirectionalAssociationMustReturnSameResourceAssociationSetFromBothEnd); } } if (end.ResourceProperty != null) { str2 = string.Concat(new object[] { end.ResourceSet.Name, '_', end.ResourceType.FullName, '_', end.ResourceProperty.Name }); } else { str2 = string.Concat(new object[] { end.ResourceSet.Name, "_Null_", resourceType.FullName, '_', navigationProperty.Name }); } if (this.associationSetByKeyCache.TryGetValue(str2, out str3)) { throw new InvalidOperationException(System.Data.Services.Strings.ResourceAssociationSet_MultipleAssociationSetsForTheSameAssociationTypeMustNotReferToSameEndSets(str3, resourceAssociationSet.Name, end.ResourceSet.Name)); } ResourceAssociationType resourceAssociationType = resourceAssociationSet.ResourceAssociationType; this.PairUpNavigationPropertyWithResourceAssociationSet(entityContainer, resourceAssociationSet, resourceAssociationType, resourceType, navigationProperty); this.associationSetByKeyCache.Add(str2, resourceAssociationSet.Name); this.associationSetByKeyCache.Add(key, resourceAssociationSet.Name); } } }
private void EnsureEntityContainers() { if (!this.HasCacheState(MetadataProviderState.EntityContainers)) { string containerName = this.metadataProvider.ContainerName; string containerNamespace = this.GetContainerNamespace(); MetadataProviderEdmEntityContainer container = this.EnsureDefaultEntityContainer(); IEnumerable <ResourceSetWrapper> resourceSets = this.metadataProvider.GetResourceSets(); if (resourceSets != null) { foreach (ResourceSetWrapper wrapper in resourceSets) { MetadataProviderEdmEntityContainer container2; string key = wrapper.EntityContainerName ?? containerName; if (!this.entityContainerCache.TryGetValue(key, out container2)) { container2 = new MetadataProviderEdmEntityContainer(this, key, containerNamespace); MetadataProviderUtils.ConvertCustomAnnotations(this, this.metadataProvider.GetEntityContainerAnnotations(key), container2); this.entityContainerCache.Add(containerNamespace + '.' + key, container2); this.entityContainerCache.Add(key, container2); } string entitySetName = MetadataProviderUtils.GetEntitySetName(wrapper.ResourceSet); container2.AddEntitySet(entitySetName, wrapper); } } IEnumerable <OperationWrapper> visibleOperations = this.metadataProvider.GetVisibleOperations(this.operationContext); if (visibleOperations != null) { foreach (OperationWrapper wrapper2 in visibleOperations) { container.EnsureFunctionImport(wrapper2); } } this.SetCacheState(MetadataProviderState.EntityContainers); } }
private void PairUpNavigationPropertyWithResourceAssociationSet(MetadataProviderEdmEntityContainer entityContainer, ResourceAssociationSet resourceAssociationSet, ResourceAssociationType resourceAssociationType, ResourceType resourceType, ResourceProperty navigationProperty) { string associationEndName; EdmMultiplicity multiplicity; EdmOnDeleteAction deleteBehavior; string str3; EdmMultiplicity multiplicity2; EdmOnDeleteAction none; string typeNamespace; bool flag = (resourceAssociationSet.End1.ResourceProperty != null) && (resourceAssociationSet.End2.ResourceProperty != null); string entitySetName = MetadataProviderUtils.GetEntitySetName(resourceAssociationSet.End1.ResourceSet); string name = MetadataProviderUtils.GetEntitySetName(resourceAssociationSet.End2.ResourceSet); bool isPrinciple = false; List<IEdmStructuralProperty> dependentProperties = null; if (resourceAssociationType != null) { associationEndName = resourceAssociationType.End1.Name; deleteBehavior = resourceAssociationType.End1.DeleteBehavior; multiplicity2 = MetadataProviderUtils.ConvertMultiplicity(resourceAssociationType.End1.Multiplicity); str3 = resourceAssociationType.End2.Name; none = resourceAssociationType.End2.DeleteBehavior; multiplicity = MetadataProviderUtils.ConvertMultiplicity(resourceAssociationType.End2.Multiplicity); ResourceReferentialConstraint referentialConstraint = resourceAssociationType.ReferentialConstraint; if (referentialConstraint != null) { isPrinciple = object.ReferenceEquals(resourceAssociationType.End1, referentialConstraint.PrincipalEnd); IEdmEntityType type = isPrinciple ? ((IEdmEntityType) this.EnsureSchemaType(resourceAssociationSet.End2.ResourceType)) : ((IEdmEntityType) this.EnsureSchemaType(resourceAssociationSet.End1.ResourceType)); dependentProperties = new List<IEdmStructuralProperty>(); foreach (ResourceProperty property in referentialConstraint.DependentProperties) { IEdmProperty property2 = type.FindProperty(property.Name); dependentProperties.Add((IEdmStructuralProperty) property2); } } } else { if (!flag) { if (resourceAssociationSet.End1.ResourceProperty != null) { associationEndName = resourceType.Name; str3 = navigationProperty.Name; } else { associationEndName = navigationProperty.Name; str3 = resourceType.Name; } } else { associationEndName = MetadataProviderUtils.GetAssociationEndName(resourceAssociationSet.End1.ResourceType, resourceAssociationSet.End1.ResourceProperty); str3 = MetadataProviderUtils.GetAssociationEndName(resourceAssociationSet.End2.ResourceType, resourceAssociationSet.End2.ResourceProperty); } multiplicity = MetadataProviderUtils.GetMultiplicity(resourceAssociationSet.End1.ResourceProperty); deleteBehavior = EdmOnDeleteAction.None; multiplicity2 = MetadataProviderUtils.GetMultiplicity(resourceAssociationSet.End2.ResourceProperty); none = EdmOnDeleteAction.None; } string associationName = (resourceAssociationType == null) ? MetadataProviderUtils.GetAssociationName(resourceAssociationSet) : resourceAssociationType.Name; if ((resourceAssociationType == null) || (resourceAssociationType.NamespaceName == null)) { ResourceAssociationSetEnd end = (resourceAssociationSet.End1.ResourceProperty != null) ? resourceAssociationSet.End1 : resourceAssociationSet.End2; typeNamespace = this.GetTypeNamespace(end.ResourceType); } else { typeNamespace = resourceAssociationType.NamespaceName; } ResourceProperty resourceProperty = resourceAssociationSet.End1.ResourceProperty; ResourceProperty property4 = resourceAssociationSet.End2.ResourceProperty; MetadataProviderEdmNavigationProperty partnerProperty = null; MetadataProviderEdmNavigationProperty property6 = null; if (resourceProperty != null) { IEdmEntityType type2 = (IEdmEntityType) this.EnsureSchemaType(resourceAssociationSet.End1.ResourceType); partnerProperty = (MetadataProviderEdmNavigationProperty) type2.FindProperty(resourceProperty.Name); } if (property4 != null) { IEdmEntityType type3 = (IEdmEntityType) this.EnsureSchemaType(resourceAssociationSet.End2.ResourceType); property6 = (MetadataProviderEdmNavigationProperty) type3.FindProperty(property4.Name); } IEdmNavigationProperty property7 = (partnerProperty != null) ? ((IEdmNavigationProperty) partnerProperty) : ((IEdmNavigationProperty) new MetadataProviderEdmSilentNavigationProperty(property6, deleteBehavior, multiplicity, associationEndName)); IEdmNavigationProperty partner = (property6 != null) ? ((IEdmNavigationProperty) property6) : ((IEdmNavigationProperty) new MetadataProviderEdmSilentNavigationProperty(partnerProperty, none, multiplicity2, str3)); MetadataProviderUtils.FixUpNavigationPropertyWithAssociationSetData(property7, partner, isPrinciple, dependentProperties, deleteBehavior, multiplicity); MetadataProviderUtils.FixUpNavigationPropertyWithAssociationSetData(partner, property7, !isPrinciple, dependentProperties, none, multiplicity2); EdmEntitySet entitySet = (EdmEntitySet) entityContainer.FindEntitySet(entitySetName); EdmEntitySet target = (EdmEntitySet) entityContainer.FindEntitySet(name); if (partnerProperty != null) { entitySet.AddNavigationTarget(partnerProperty, target); this.SetAssociationSetName(entitySet, partnerProperty, resourceAssociationSet.Name); this.SetAssociationSetAnnotations(entitySet, partnerProperty, MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.End1.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.End2.CustomAnnotations)); } if (property6 != null) { target.AddNavigationTarget(property6, entitySet); this.SetAssociationSetName(target, property6, resourceAssociationSet.Name); if (partnerProperty == null) { this.SetAssociationSetAnnotations(entitySet, property6, MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.End1.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.End2.CustomAnnotations)); } } this.SetAssociationNamespace(property7, typeNamespace); this.SetAssociationName(property7, associationName); this.SetAssociationEndName(property7, associationEndName); this.SetAssociationNamespace(partner, typeNamespace); this.SetAssociationName(partner, associationName); this.SetAssociationEndName(partner, str3); if (resourceAssociationType != null) { this.SetAssociationAnnotations(property7, MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationType.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, (property7.GetPrimary() == property7) ? resourceAssociationType.End1.CustomAnnotations : resourceAssociationType.End2.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, (property7.GetPrimary() == property7) ? resourceAssociationType.End2.CustomAnnotations : resourceAssociationType.End1.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, (resourceAssociationType.ReferentialConstraint != null) ? resourceAssociationType.ReferentialConstraint.CustomAnnotations : null)); } }
private void PairUpNavigationProperty(MetadataProviderEdmEntityContainer entityContainer, ResourceSetWrapper resourceSet, ResourceType resourceType, ResourceProperty navigationProperty) { string key = string.Concat(new object[] { resourceSet.Name, '_', resourceType.FullName, '_', navigationProperty.Name }); if (!this.associationSetByKeyCache.ContainsKey(key)) { ResourceAssociationSet resourceAssociationSet = this.MetadataProvider.GetResourceAssociationSet(resourceSet, resourceType, navigationProperty); if (resourceAssociationSet != null) { string str2; string str3; ResourceAssociationSetEnd end = resourceAssociationSet.GetRelatedResourceAssociationSetEnd(resourceSet, resourceType, navigationProperty); if (end.ResourceProperty != null) { ResourceAssociationSet set2 = this.MetadataProvider.GetResourceAssociationSet(this.MetadataProvider.ValidateResourceSet(end.ResourceSet), end.ResourceType, end.ResourceProperty); if ((set2 == null) || (resourceAssociationSet.Name != set2.Name)) { throw new InvalidOperationException(System.Data.Services.Strings.ResourceAssociationSet_BidirectionalAssociationMustReturnSameResourceAssociationSetFromBothEnd); } } if (end.ResourceProperty != null) { str2 = string.Concat(new object[] { end.ResourceSet.Name, '_', end.ResourceType.FullName, '_', end.ResourceProperty.Name }); } else { str2 = string.Concat(new object[] { end.ResourceSet.Name, "_Null_", resourceType.FullName, '_', navigationProperty.Name }); } if (this.associationSetByKeyCache.TryGetValue(str2, out str3)) { throw new InvalidOperationException(System.Data.Services.Strings.ResourceAssociationSet_MultipleAssociationSetsForTheSameAssociationTypeMustNotReferToSameEndSets(str3, resourceAssociationSet.Name, end.ResourceSet.Name)); } ResourceAssociationType resourceAssociationType = resourceAssociationSet.ResourceAssociationType; this.PairUpNavigationPropertyWithResourceAssociationSet(entityContainer, resourceAssociationSet, resourceAssociationType, resourceType, navigationProperty); this.associationSetByKeyCache.Add(str2, resourceAssociationSet.Name); this.associationSetByKeyCache.Add(key, resourceAssociationSet.Name); } } }
private void PairUpNavigationPropertiesForEntitySetAndType(MetadataProviderEdmEntityContainer entityContainer, ResourceSetWrapper resourceSet, ResourceType resourceType) { IEnumerable<ResourceProperty> allVisiblePropertiesDeclaredInThisType = this.GetAllVisiblePropertiesDeclaredInThisType(resourceType); if (allVisiblePropertiesDeclaredInThisType != null) { foreach (ResourceProperty property in from p in allVisiblePropertiesDeclaredInThisType where p.TypeKind == ResourceTypeKind.EntityType select p) { this.PairUpNavigationProperty(entityContainer, resourceSet, resourceType, property); } } }
private void PairUpNavigationPropertiesForEntitySet(MetadataProviderEdmEntityContainer entityContainer, ResourceSetWrapper resourceSet) { foreach (ResourceType type in this.MetadataProvider.GetDerivedTypes(resourceSet.ResourceType)) { this.PairUpNavigationPropertiesForEntitySetAndType(entityContainer, resourceSet, type); } for (ResourceType type2 = resourceSet.ResourceType; type2 != null; type2 = type2.BaseType) { this.PairUpNavigationPropertiesForEntitySetAndType(entityContainer, resourceSet, type2); } }
private void EnsureEntityContainers() { if (!this.HasCacheState(MetadataProviderState.EntityContainers)) { string containerName = this.metadataProvider.ContainerName; string containerNamespace = this.GetContainerNamespace(); MetadataProviderEdmEntityContainer container = this.EnsureDefaultEntityContainer(); IEnumerable<ResourceSetWrapper> resourceSets = this.metadataProvider.GetResourceSets(); if (resourceSets != null) { foreach (ResourceSetWrapper wrapper in resourceSets) { MetadataProviderEdmEntityContainer container2; string key = wrapper.EntityContainerName ?? containerName; if (!this.entityContainerCache.TryGetValue(key, out container2)) { container2 = new MetadataProviderEdmEntityContainer(this, key, containerNamespace); MetadataProviderUtils.ConvertCustomAnnotations(this, this.metadataProvider.GetEntityContainerAnnotations(key), container2); this.entityContainerCache.Add(containerNamespace + '.' + key, container2); this.entityContainerCache.Add(key, container2); } string entitySetName = MetadataProviderUtils.GetEntitySetName(wrapper.ResourceSet); container2.AddEntitySet(entitySetName, wrapper); } } IEnumerable<OperationWrapper> visibleOperations = this.metadataProvider.GetVisibleOperations(this.operationContext); if (visibleOperations != null) { foreach (OperationWrapper wrapper2 in visibleOperations) { container.EnsureFunctionImport(wrapper2); } } this.SetCacheState(MetadataProviderState.EntityContainers); } }
internal MetadataProviderEdmEntityContainer EnsureDefaultEntityContainer() { MetadataProviderEdmEntityContainer container; string containerName = this.metadataProvider.ContainerName; if (!this.entityContainerCache.TryGetValue(containerName, out container)) { container = new MetadataProviderEdmEntityContainer(this, containerName, this.GetContainerNamespace()); this.SetIsDefaultEntityContainer(container, true); MetadataProviderUtils.ConvertCustomAnnotations(this, this.metadataProvider.GetEntityContainerAnnotations(containerName), container); this.entityContainerCache.Add(containerName, container); this.entityContainerCache.Add(container.FullName(), container); } return container; }
private void PairUpNavigationPropertyWithResourceAssociationSet(MetadataProviderEdmEntityContainer entityContainer, ResourceAssociationSet resourceAssociationSet, ResourceAssociationType resourceAssociationType, ResourceType resourceType, ResourceProperty navigationProperty) { string associationEndName; EdmMultiplicity multiplicity; EdmOnDeleteAction deleteBehavior; string str3; EdmMultiplicity multiplicity2; EdmOnDeleteAction none; string typeNamespace; bool flag = (resourceAssociationSet.End1.ResourceProperty != null) && (resourceAssociationSet.End2.ResourceProperty != null); string entitySetName = MetadataProviderUtils.GetEntitySetName(resourceAssociationSet.End1.ResourceSet); string name = MetadataProviderUtils.GetEntitySetName(resourceAssociationSet.End2.ResourceSet); bool isPrinciple = false; List <IEdmStructuralProperty> dependentProperties = null; if (resourceAssociationType != null) { associationEndName = resourceAssociationType.End1.Name; deleteBehavior = resourceAssociationType.End1.DeleteBehavior; multiplicity2 = MetadataProviderUtils.ConvertMultiplicity(resourceAssociationType.End1.Multiplicity); str3 = resourceAssociationType.End2.Name; none = resourceAssociationType.End2.DeleteBehavior; multiplicity = MetadataProviderUtils.ConvertMultiplicity(resourceAssociationType.End2.Multiplicity); ResourceReferentialConstraint referentialConstraint = resourceAssociationType.ReferentialConstraint; if (referentialConstraint != null) { isPrinciple = object.ReferenceEquals(resourceAssociationType.End1, referentialConstraint.PrincipalEnd); IEdmEntityType type = isPrinciple ? ((IEdmEntityType)this.EnsureSchemaType(resourceAssociationSet.End2.ResourceType)) : ((IEdmEntityType)this.EnsureSchemaType(resourceAssociationSet.End1.ResourceType)); dependentProperties = new List <IEdmStructuralProperty>(); foreach (ResourceProperty property in referentialConstraint.DependentProperties) { IEdmProperty property2 = type.FindProperty(property.Name); dependentProperties.Add((IEdmStructuralProperty)property2); } } } else { if (!flag) { if (resourceAssociationSet.End1.ResourceProperty != null) { associationEndName = resourceType.Name; str3 = navigationProperty.Name; } else { associationEndName = navigationProperty.Name; str3 = resourceType.Name; } } else { associationEndName = MetadataProviderUtils.GetAssociationEndName(resourceAssociationSet.End1.ResourceType, resourceAssociationSet.End1.ResourceProperty); str3 = MetadataProviderUtils.GetAssociationEndName(resourceAssociationSet.End2.ResourceType, resourceAssociationSet.End2.ResourceProperty); } multiplicity = MetadataProviderUtils.GetMultiplicity(resourceAssociationSet.End1.ResourceProperty); deleteBehavior = EdmOnDeleteAction.None; multiplicity2 = MetadataProviderUtils.GetMultiplicity(resourceAssociationSet.End2.ResourceProperty); none = EdmOnDeleteAction.None; } string associationName = (resourceAssociationType == null) ? MetadataProviderUtils.GetAssociationName(resourceAssociationSet) : resourceAssociationType.Name; if ((resourceAssociationType == null) || (resourceAssociationType.NamespaceName == null)) { ResourceAssociationSetEnd end = (resourceAssociationSet.End1.ResourceProperty != null) ? resourceAssociationSet.End1 : resourceAssociationSet.End2; typeNamespace = this.GetTypeNamespace(end.ResourceType); } else { typeNamespace = resourceAssociationType.NamespaceName; } ResourceProperty resourceProperty = resourceAssociationSet.End1.ResourceProperty; ResourceProperty property4 = resourceAssociationSet.End2.ResourceProperty; MetadataProviderEdmNavigationProperty partnerProperty = null; MetadataProviderEdmNavigationProperty property6 = null; if (resourceProperty != null) { IEdmEntityType type2 = (IEdmEntityType)this.EnsureSchemaType(resourceAssociationSet.End1.ResourceType); partnerProperty = (MetadataProviderEdmNavigationProperty)type2.FindProperty(resourceProperty.Name); } if (property4 != null) { IEdmEntityType type3 = (IEdmEntityType)this.EnsureSchemaType(resourceAssociationSet.End2.ResourceType); property6 = (MetadataProviderEdmNavigationProperty)type3.FindProperty(property4.Name); } IEdmNavigationProperty property7 = (partnerProperty != null) ? ((IEdmNavigationProperty)partnerProperty) : ((IEdmNavigationProperty) new MetadataProviderEdmSilentNavigationProperty(property6, deleteBehavior, multiplicity, associationEndName)); IEdmNavigationProperty partner = (property6 != null) ? ((IEdmNavigationProperty)property6) : ((IEdmNavigationProperty) new MetadataProviderEdmSilentNavigationProperty(partnerProperty, none, multiplicity2, str3)); MetadataProviderUtils.FixUpNavigationPropertyWithAssociationSetData(property7, partner, isPrinciple, dependentProperties, deleteBehavior, multiplicity); MetadataProviderUtils.FixUpNavigationPropertyWithAssociationSetData(partner, property7, !isPrinciple, dependentProperties, none, multiplicity2); EdmEntitySet entitySet = (EdmEntitySet)entityContainer.FindEntitySet(entitySetName); EdmEntitySet target = (EdmEntitySet)entityContainer.FindEntitySet(name); if (partnerProperty != null) { entitySet.AddNavigationTarget(partnerProperty, target); this.SetAssociationSetName(entitySet, partnerProperty, resourceAssociationSet.Name); this.SetAssociationSetAnnotations(entitySet, partnerProperty, MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.End1.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.End2.CustomAnnotations)); } if (property6 != null) { target.AddNavigationTarget(property6, entitySet); this.SetAssociationSetName(target, property6, resourceAssociationSet.Name); if (partnerProperty == null) { this.SetAssociationSetAnnotations(entitySet, property6, MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.End1.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationSet.End2.CustomAnnotations)); } } this.SetAssociationNamespace(property7, typeNamespace); this.SetAssociationName(property7, associationName); this.SetAssociationEndName(property7, associationEndName); this.SetAssociationNamespace(partner, typeNamespace); this.SetAssociationName(partner, associationName); this.SetAssociationEndName(partner, str3); if (resourceAssociationType != null) { this.SetAssociationAnnotations(property7, MetadataProviderUtils.ConvertCustomAnnotations(this, resourceAssociationType.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, (property7.GetPrimary() == property7) ? resourceAssociationType.End1.CustomAnnotations : resourceAssociationType.End2.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, (property7.GetPrimary() == property7) ? resourceAssociationType.End2.CustomAnnotations : resourceAssociationType.End1.CustomAnnotations), MetadataProviderUtils.ConvertCustomAnnotations(this, (resourceAssociationType.ReferentialConstraint != null) ? resourceAssociationType.ReferentialConstraint.CustomAnnotations : null)); } }