private static void AddNavigationBindings(NavigationSourceConfiguration configuration, EdmNavigationSource navigationSource, NavigationSourceLinkBuilderAnnotation linkBuilder, ODataModelBuilder builder, Dictionary <Type, IEdmType> edmTypeMap, Dictionary <string, EdmNavigationSource> edmNavigationSourceMap) { foreach (EntityTypeConfiguration entityType in builder.ThisAndBaseAndDerivedTypes(configuration.EntityType)) { foreach (NavigationPropertyConfiguration navigationProperty in entityType.NavigationProperties) { NavigationPropertyBindingConfiguration binding = configuration.FindBinding(navigationProperty); bool isContained = navigationProperty.ContainsTarget; if (binding != null || isContained) { EdmEntityType edmEntityType = edmTypeMap[entityType.ClrType] as EdmEntityType; IEdmNavigationProperty edmNavigationProperty = edmEntityType.NavigationProperties() .Single(np => np.Name == navigationProperty.Name); if (!isContained) { navigationSource.AddNavigationTarget( edmNavigationProperty, edmNavigationSourceMap[binding.TargetNavigationSource.Name]); } NavigationLinkBuilder linkBuilderFunc = configuration.GetNavigationPropertyLink(navigationProperty); if (linkBuilderFunc != null) { linkBuilder.AddNavigationPropertyLinkBuilder(edmNavigationProperty, linkBuilderFunc); } } } } }
private static void AddNavigationBindings(NavigationSourceConfiguration configuration, EdmNavigationSource navigationSource, NavigationSourceLinkBuilderAnnotation linkBuilder, ODataModelBuilder builder, Dictionary<Type, IEdmType> edmTypeMap, Dictionary<string, EdmNavigationSource> edmNavigationSourceMap) { foreach (EntityTypeConfiguration entityType in builder.ThisAndBaseAndDerivedTypes(configuration.EntityType)) { foreach (NavigationPropertyConfiguration navigationProperty in entityType.NavigationProperties) { NavigationPropertyBindingConfiguration binding = configuration.FindBinding(navigationProperty); bool isContained = navigationProperty.ContainsTarget; if (binding != null || isContained) { EdmEntityType edmEntityType = edmTypeMap[entityType.ClrType] as EdmEntityType; IEdmNavigationProperty edmNavigationProperty = edmEntityType.NavigationProperties() .Single(np => np.Name == navigationProperty.Name); if (!isContained) { navigationSource.AddNavigationTarget( edmNavigationProperty, edmNavigationSourceMap[binding.TargetNavigationSource.Name]); } NavigationLinkBuilder linkBuilderFunc = configuration.GetNavigationPropertyLink(navigationProperty); if (linkBuilderFunc != null) { linkBuilder.AddNavigationPropertyLinkBuilder(edmNavigationProperty, linkBuilderFunc); } } } } }
/// <summary> /// Finds the <see cref="NavigationPropertyBindingConfiguration"/> for the navigation property with the given name. /// </summary> /// <param name="propertyName">The name of the navigation property.</param> /// <returns>The binding, if found; otherwise, <see langword="null"/>.</returns> public NavigationPropertyBindingConfiguration FindBinding(string propertyName) { return(_configuration.FindBinding(propertyName)); }
/// <summary> /// Finds the bindings <see cref="NavigationPropertyBindingConfiguration"/> for the given navigation property /// </summary> /// <param name="navigationConfiguration">The navigation property.</param> /// <returns>The bindings if found</returns> public IEnumerable <NavigationPropertyBindingConfiguration> FindBinding(NavigationPropertyConfiguration navigationConfiguration) { return(_configuration.FindBinding(navigationConfiguration)); }