internal void Resolve(SchemaInfo schemaInfo) { if (parentSchema != null) { // already resolved, probably as part of included schema Resolve() process return; } parentSchema = schemaInfo; Table.Resolve(this.Name, true); Table.Rehash(); Table.Fields[0].ReferencedClass = schemaInfo.FindClassByName(Table.Fields[0].References); if (Table.Fields[0].ReferencedClass == null) { throw new SoodaSchemaException("Class " + Table.Fields[0].References + " not found in " + this.Name + "." + Table.Fields[0].Name); } Table.Fields[1].ReferencedClass = schemaInfo.FindClassByName(Table.Fields[1].References); if (Table.Fields[1].ReferencedClass == null) { throw new SoodaSchemaException("Class " + Table.Fields[1].References + " not found in " + this.Name + "." + Table.Fields[1].Name); } foreach (FieldInfo fi in Table.Fields) { fi.ParentRelation = this; } }
internal void MergeTables() { DatabaseTables = new List <TableInfo>(); Dictionary <string, TableInfo> mergedTables = new Dictionary <string, TableInfo>(); foreach (TableInfo table in UnifiedTables) { TableInfo mt; if (!mergedTables.TryGetValue(table.DBTableName, out mt)) { mt = new TableInfo(); mt.DBTableName = table.DBTableName; mt.TableUsageType = table.TableUsageType; mt.OrdinalInClass = -1; mt.Rehash(); mergedTables[table.DBTableName] = mt; DatabaseTables.Add(mt); } foreach (FieldInfo fi in table.Fields) { if (mt.ContainsField(fi.Name)) { if (!fi.IsPrimaryKey) { throw new SoodaSchemaException("Duplicate field found for one table!"); } continue; } mt.Fields.Add(fi); } mt.Rehash(); } }
internal void MergeTables() { DatabaseTables = new List<TableInfo>(); Dictionary<string, TableInfo> mergedTables = new Dictionary<string, TableInfo>(); foreach (TableInfo table in UnifiedTables) { TableInfo mt; if (!mergedTables.TryGetValue(table.DBTableName, out mt)) { mt = new TableInfo(); mt.DBTableName = table.DBTableName; mt.TableUsageType = table.TableUsageType; mt.OrdinalInClass = -1; mt.Rehash(); mergedTables[table.DBTableName] = mt; DatabaseTables.Add(mt); } foreach (FieldInfo fi in table.Fields) { if (mt.ContainsField(fi.Name)) { if (!fi.IsPrimaryKey) throw new SoodaSchemaException("Duplicate field found for one table!"); continue; } mt.Fields.Add(fi); } mt.Rehash(); } }