public static EntityType AddTable(this EdmModel database, string name) { DebugCheck.NotEmpty(name); var uniqueIdentifier = database.EntityTypes.UniquifyName(name); var table = new EntityType( uniqueIdentifier, DefaultStoreNamespace, DataSpace.SSpace); database.AddItem(table); database.AddEntitySet(table.Name, table, uniqueIdentifier); return table; }
public static void ConfigureFromContainer(this ODataModelBuilder modelBuilder, IContainerMetadata containerMetadata) { modelBuilder.ContainerName = containerMetadata.Name; modelBuilder.Namespace = containerMetadata.Namespace; // Add all entity types foreach (IEntityTypeMetadata entityTypeMetadata in containerMetadata.EntityTypes) { EntityTypeConfiguration entityTypeConfig = modelBuilder.AddEntity(entityTypeMetadata.ClrType); } // Add all entity sets foreach (IEntitySetMetadata entitySetMetadata in containerMetadata.EntitySets) { string entitySetName = entitySetMetadata.Name; EntityTypeConfiguration entityTypeConfig = (EntityTypeConfiguration) modelBuilder.GetTypeConfigurationOrNull(entitySetMetadata.ElementTypeMetadata.ClrType); EntitySetConfiguration entitySetConfig = modelBuilder.AddEntitySet(entitySetName, entityTypeConfig); } }
private static EdmEntitySet AddEntitySet(this EdmEntityContainer container, EntitySetConfiguration entitySet, IDictionary<Type, IEdmType> edmTypeMap) { return container.AddEntitySet(entitySet.Name, (IEdmEntityType)edmTypeMap[entitySet.EntityType.ClrType]); }
private static EdmEntitySet AddEntitySet(this EdmEntityContainer container, IEntitySetConfiguration entitySet, IDictionary<string, IEdmStructuredType> edmTypeMap) { return container.AddEntitySet(entitySet.Name, (IEdmEntityType)edmTypeMap[entitySet.EntityType.FullName]); }