public static SchemaDefinition MapSchemaClassAndPropertyNames(SchemaNameMap nameMap, SchemaDefinition schema)
        {
            SchemaManager mgr = new SchemaManager(schema);

            mgr.AutoSave = false;
            Parallel.ForEach(nameMap.TableNamesToClassNames, (map) =>
            {
                mgr.SetTableClassName(map.TableName, map.ClassName);
            });
            Parallel.ForEach(schema.Tables, (table) =>
            {
                Parallel.ForEach(table.Columns, column => mgr.SetColumnPropertyName(table.Name, column.Name, nameMap.GetPropertyName(table.Name, column.Name)));
            });
            return(mgr.CurrentSchema);
        }
示例#2
0
 public SchemaExtractor()
 {
     NameMap                = new SchemaNameMap();
     NameFormatter          = new SchemaNameMapNameFormatter(NameMap);
     SchemaTempPathProvider = sd => RuntimeSettings.AppDataFolder;
     _namingCollisionHandlers.Add(SchemaExtractorNamingCollisionStrategy.LeadingUnderscore, (tableName, columnName, propertyName) => $"_{columnName}");
     _namingCollisionHandlers.Add(SchemaExtractorNamingCollisionStrategy.TrailingUnderscore, (tableName, columnName, propertyName) => $"{columnName}_");
     _namingCollisionHandlers.Add(SchemaExtractorNamingCollisionStrategy.TypePrefix, (tableName, columnName, propertyName) => $"{GetColumnDataType(tableName, columnName).ToString()}{columnName}");
     _namingCollisionHandlers.Add(SchemaExtractorNamingCollisionStrategy.TypeSuffix, (tableName, columnName, propertyName) => $"{columnName}{GetColumnDataType(tableName, columnName).ToString()}");
     _namingCollisionHandlers.Add(SchemaExtractorNamingCollisionStrategy.UnderscoreDelimit, (tableName, columnName, propertyName) => $"_{columnName}_");
     _namingCollisionHandlers.Add(SchemaExtractorNamingCollisionStrategy.Custom, (tableName, columnName, propertyName) => CustomNamingCollisionHandler(tableName, columnName, propertyName));
     _namingCollisionHandlers.Add(SchemaExtractorNamingCollisionStrategy.Invalid, (tableName, columnName, propertyName) =>
     {
         throw new InvalidOperationException("Invalid SchemaExtractorNamingCollisionStrategy specified");
     });
     CustomNamingCollisionHandler           = _namingCollisionHandlers[SchemaExtractorNamingCollisionStrategy.TrailingUnderscore];
     SchemaExtractorNamingCollisionStrategy = SchemaExtractorNamingCollisionStrategy.TrailingUnderscore;
 }
 public MappedSchemaDefinition(SchemaDefinition definition, SchemaNameMap nameMap)
     : this()
 {
     this.SchemaNameMap    = nameMap;
     this.SchemaDefinition = definition;
 }
 public SchemaNameMapNameFormatter(SchemaNameMap nameMap)
 {
     this.NameMap = nameMap;
 }