/// <summary> /// Builds <see cref="IEdmType"/> and <see cref="IEdmProperty"/>'s from <paramref name="configurations"/> /// </summary> /// <param name="configurations">A collection of <see cref="IEdmTypeConfiguration"/>'s</param> /// <returns>The built dictionary of <see cref="StructuralTypeConfiguration"/>'s indexed by their backing CLR type, /// and dictionary of <see cref="StructuralTypeConfiguration"/>'s indexed by their backing CLR property info</returns> public static EdmTypeMap GetTypesAndProperties(IEnumerable <IEdmTypeConfiguration> configurations) { if (configurations == null) { throw Error.ArgumentNull("configurations"); } EdmTypeBuilder builder = new EdmTypeBuilder(configurations); return(new EdmTypeMap(builder.GetEdmTypes(), builder._properties, builder._propertiesRestrictions, builder._propertiesQuerySettings, builder._structuredTypeQuerySettings, builder._members, builder._openTypes)); }
public static IEdmModel BuildEdmModel(ODataModelBuilder builder) { if (builder == null) { throw Error.ArgumentNull("builder"); } EdmModel model = new EdmModel(); EdmEntityContainer container = new EdmEntityContainer(builder.Namespace, builder.ContainerName); // add types and sets, building an index on the way. IEnumerable <IEdmTypeConfiguration> configTypes = builder.StructuralTypes.Concat <IEdmTypeConfiguration>(builder.EnumTypes); EdmTypeMap edmMap = EdmTypeBuilder.GetTypesAndProperties(configTypes); Dictionary <Type, IEdmType> edmTypeMap = model.AddTypes(edmMap); // Add EntitySets and build the mapping between the EdmEntitySet and the NavigationSourceConfiguration NavigationSourceAndAnnotations[] entitySets = container.AddEntitySetAndAnnotations(builder, edmTypeMap); // Add Singletons and build the mapping between the EdmSingleton and the NavigationSourceConfiguration NavigationSourceAndAnnotations[] singletons = container.AddSingletonAndAnnotations(builder, edmTypeMap); // Merge EntitySets and Singletons together IEnumerable <NavigationSourceAndAnnotations> navigationSources = entitySets.Concat(singletons); // Build the navigation source map IDictionary <string, EdmNavigationSource> navigationSourceMap = model.GetNavigationSourceMap(edmMap, navigationSources); // Add the core vocabulary annotations model.AddCoreVocabularyAnnotations(navigationSources, edmMap); // TODO: support etags on contained nav props // Support for this in 5.x adds annotations to navigation properties. Ideally would add annotations to entity set/singleton for // containing type(s) with nav paths to the contained nav property. // model.AddNavPropAnnotations(builder, edmMap); // implemented in EdmModelHelperMethods.cs of 5.x branch // Add the capabilities vocabulary annotations model.AddCapabilitiesVocabularyAnnotations(navigationSources, edmMap); // finish up model.AddElement(container); // build the map from IEdmEntityType to IEdmFunctionImport model.SetAnnotationValue <BindableOperationFinder>(model, new BindableOperationFinder(model)); return(model); }