protected override void AddSchemaTables(TypeSchema typeSchema, SchemaManager schemaManager, ITypeTableNameProvider tableNameProvider = null) { tableNameProvider = tableNameProvider ?? new EchoTypeTableNameProvider(); foreach (Type topType in typeSchema.Tables) { TypeInheritanceDescriptor inheritance = new TypeInheritanceDescriptor(topType); Type inheritFrom = null; inheritance.Chain.BackwardsEach(typeTable => { string tableName = typeTable.GetTableName(tableNameProvider); schemaManager.AddTable(tableName); schemaManager.ExecutePreColumnAugmentations(tableName); typeTable.PropertyColumns.Each(pc => { AddPropertyColumn(schemaManager, typeSchema.DefaultDataTypeBehavior, tableName, pc.PropertyInfo); }); schemaManager.ExecutePostColumnAugmentations(tableName); schemaManager.AddColumn(tableName, "Id", DataTypes.Long); if (inheritFrom != null) { schemaManager.SetForeignKey(tableNameProvider.GetTableName(inheritFrom), tableName, "Id", "Id"); } else { schemaManager.SetKeyColumn(tableName, "Id"); } inheritFrom = typeTable.Type; }); } }
protected virtual void AddSchemaTables(TypeSchema typeSchema, SchemaManager schemaManager, ITypeTableNameProvider tableNameProvider = null) { tableNameProvider = tableNameProvider ?? new EchoTypeTableNameProvider(); foreach (Type tableType in typeSchema.Tables) { string tableName = GetTableNameForType(tableType, tableNameProvider); schemaManager.AddTable(tableName); schemaManager.ExecutePreColumnAugmentations(tableName); AddPropertyColumns(tableType, schemaManager, typeSchema.DefaultDataTypeBehavior); schemaManager.ExecutePostColumnAugmentations(tableName); } }