コード例 #1
0
ファイル: DbSchemaFactory.cs プロジェクト: priyanr/effort
        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
ファイル: DbSchemaFactory.cs プロジェクト: nozerowu/ABP
        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();
        }