public void AliasUsed(string alias, string table) { DbTable t = tables[table]; tablesByAlias.AddIfNotExists(alias, t); tablesByAlias.SetPosition(alias, t.AliasUsed(alias)); activeTables.AddIfNotExists(t); }
DbTable GetDbTable(ColumnParts parts) { foreach (DbColumn c in Query.columnHints) { if (c.name == parts.t.name) { if (parts.alias == null) { return(c.table); } if (c.table.aliases.ContainsKey(parts.alias)) { return(c.table); } candidateTables.AddIfNotExists(c.table, parts.t); } } DbTable dbTable = null; int ct = Query.Db.tablesByColumnName.ValueCount(parts.t.name); if (ct == 1) { dbTable = Query.Db.tablesByColumnName[parts.t.name]; } foreach (DbTable tmp in Query.Db.tablesByColumnName.Each(parts.t.name)) { candidateTables.AddIfNotExists(tmp, parts.t); } if (dbTable == null && parts.alias == null) { foreach (DbColumn c in Query.Db.activeColumns) { if (c.name == parts.t.name) { return(c.table); } } } if (dbTable == null && parts.alias != null) { ct = Query.Db.tablesByAlias.ValueCount(parts.alias); if (ct == 1 && Query.Db.tablesByAlias[parts.alias].columns.ContainsKey(parts.t.name)) { dbTable = Query.Db.tablesByAlias[parts.alias]; } foreach (DbTable tmp in Query.Db.tablesByAlias.Each(parts.alias)) { if (tmp.columns.ContainsKey(parts.t.name)) { candidateTables.AddIfNotExists(tmp, parts.t); } } } /* * if(dbTable == null) * { * ct = 0; * match = null; * foreach(DbTable t in Query.Db.activeTables) * { * if (t.columns.ContainsKey(parts.t.name)) * { * match = t.columns[parts.t.name]; * ct++; * } * } * if(ct == 1) * dbTable = match.table; * } */ return(dbTable); }