Пример #1
0
        public static DbSchema CreateDbSchema(StoreItemCollection edmStoreSchema)
        {
            EdmTypeConverter   converter = new EdmTypeConverter(new DefaultTypeConverter());
            CanonicalContainer container = new CanonicalContainer(edmStoreSchema, converter);

            IBareSchema bareSchema = new DynamicBareSchema(container);

            TableConfigurationGroup tableConfig = new TableConfigurationGroup();

            tableConfig.Register(new BareSchemaConfiguration(bareSchema));
            tableConfig.Register <PrimaryKeyConfiguration>();
            tableConfig.Register <IdentityConfiguration>();
            tableConfig.Register <GeneratedGuidConfiguration>();
            tableConfig.Register <NotNullConfiguration>();
            tableConfig.Register <VarcharLimitConfiguration>();
            tableConfig.Register <CharLimitConfiguration>();
            tableConfig.Register <IndexConfiguration>();

            DbSchemaBuilder schemaBuilder = new DbSchemaBuilder();

            foreach (EntityInfo entityInfo in container.Entities)
            {
                DbTableInfoBuilder tableBuilder = new DbTableInfoBuilder();

                // Run all configurations
                tableConfig.Configure(entityInfo, tableBuilder);

                schemaBuilder.Register(tableBuilder);
            }

            RelationConfigurationGroup associationConfig = new RelationConfigurationGroup();

            associationConfig.Register <RelationConfiguration>();

            foreach (AssociationInfo associationInfo in container.Associations)
            {
                associationConfig.Configure(associationInfo, schemaBuilder);
            }

            return(schemaBuilder.Create());
        }
Пример #2
0
        public static DbSchema CreateDbSchema(StoreItemCollection edmStoreSchema)
        {
            EdmTypeConverter converter = new EdmTypeConverter(new DefaultTypeConverter());
            CanonicalContainer container = new CanonicalContainer(edmStoreSchema, converter);

            IBareSchema bareSchema = new DynamicBareSchema(container);

            TableConfigurationGroup tableConfig = new TableConfigurationGroup();
            tableConfig.Register(new BareSchemaConfiguration(bareSchema));
            tableConfig.Register<PrimaryKeyConfiguration>();
            tableConfig.Register<IdentityConfiguration>();
            tableConfig.Register<GeneratedGuidConfiguration>();
            tableConfig.Register<NotNullConfiguration>();
            tableConfig.Register<VarcharLimitConfiguration>();
            tableConfig.Register<CharLimitConfiguration>();
            tableConfig.Register<IndexConfiguration>();

            DbSchemaBuilder schemaBuilder = new DbSchemaBuilder();

            foreach (EntityInfo entityInfo in container.Entities)
            {
                DbTableInfoBuilder tableBuilder = new DbTableInfoBuilder();

                // Run all configurations
                tableConfig.Configure(entityInfo, tableBuilder);

                schemaBuilder.Register(tableBuilder);
            }

            RelationConfigurationGroup associationConfig = new RelationConfigurationGroup();
            associationConfig.Register<RelationConfiguration>();

            foreach (AssociationInfo associationInfo in container.Associations)
            {
                associationConfig.Configure(associationInfo, schemaBuilder);
            }

            return schemaBuilder.Create();
        }
Пример #3
0
 public void Register(DbTableInfoBuilder table)
 {
     this.tables.Add(table);
 }
Пример #4
0
 public void Register(DbTableInfoBuilder table)
 {
     this.tables.Add(table);
 }