private void EmitFrom() { SqlTableAlias tbl; foreach (NPathClassName className in query.From.Classes) { tbl = propertyPathTraverser.GetClassTableAlias(className.Name); if (!(includedTableAliases.Contains(tbl))) { FromTable fromTable = new FromTable(); fromTable.Alias = tbl ; fromTables.Add(fromTable); includedTableAliases.Add(tbl); } } }
private string EmitLeftOuterJoin(TableJoin tableJoin, FromTable fromTable) //, StringBuilder whereBuilder) { StringBuilder clause = new StringBuilder() ; IPropertyMap propertyMap = tableJoin.PropertyMap ; ITableMap tableMap = propertyMap.MustGetTableMap(); ArrayList columnMaps = tableJoin.ColumnMaps; object hashObject = tableJoin.Parent; if (hashObject == null) { hashObject = propertyMap; } SqlTableAlias tbl = GetTableAlias(tableMap, hashObject); SqlColumnAlias col; SqlTableAlias idtbl = null; SqlColumnAlias idcol; ITableMap idTableMap; foreach (IColumnMap columnMap in columnMaps) { if (idtbl == null) { idTableMap = columnMap.MustGetPrimaryKeyTableMap(); idtbl = GetTableAlias(idTableMap, tableJoin); } col = tbl.GetSqlColumnAlias(columnMap); idcol = idtbl.GetSqlColumnAlias(columnMap.MustGetPrimaryKeyColumnMap()); fromTable.Alias = idtbl; fromTable.LinksToAlias = tbl; fromTable.Columns.Add(idcol); fromTable.LinksToColumns.Add(col); this.includedTableAliases.Add(idtbl); } if (tableJoin.BaseTableMap != null) { columnMaps = tableJoin.BaseColumnMaps; tbl = GetTableAlias(tableMap, hashObject); idtbl = null; foreach (IColumnMap columnMap in columnMaps) { if (idtbl == null) { if (hashObject is IPropertyMap) { hashObject = ((IPropertyMap) hashObject).ClassMap ; } idtbl = GetTableAlias(columnMap.MustGetPrimaryKeyTableMap(), hashObject); } col = tbl.GetSqlColumnAlias(columnMap); idcol = idtbl.GetSqlColumnAlias(columnMap.MustGetPrimaryKeyColumnMap()); // fromTable.Alias = idtbl; // fromTable.LinksToAlias = tbl; // fromTable.Columns.Add(idcol); // fromTable.LinksToColumns.Add(col); // this.includedTableAliases.Add(idtbl); fromTable.Alias = tbl; fromTable.LinksToAlias = idtbl; fromTable.Columns.Add(col); fromTable.LinksToColumns.Add(idcol); this.includedTableAliases.Add(tbl); // SqlSearchCondition search = select.SqlWhereClause.GetNextSqlSearchCondition(); // search.GetSqlComparePredicate(col, SqlCompareOperatorType.Equals, idcol); } } return clause.ToString(); }
private void RenderLeftOuterJoinFrom(FromTable tbl) { foreach ( FromTable fromTable in fromJoinTables ) { if (fromTable.LinksToAlias == tbl.Alias ) { EmitFromTable(fromTable); RenderLeftOuterJoinFrom(fromTable); } } }
private void EmitFromTable(FromTable fromTable) { if (fromTable.LinksToAlias != null) { SqlJoinTableSource join = select.SqlFromClause.AddSqlJoinTableSource(fromTable.Alias, fromTable.LinksToAlias, SqlJoinType.LeftOuter); int i = 0; foreach (SqlColumnAlias column in fromTable.Columns) { SqlColumnAlias linksToColumn = (SqlColumnAlias) fromTable.LinksToColumns[i]; SqlSearchCondition search = join.GetNextSqlSearchCondition(); search.GetSqlComparePredicate(column, SqlCompareOperatorType.Equals, linksToColumn); i++; } } else { select.SqlFromClause.AddSqlAliasTableSource(fromTable.Alias); } }
private void GetFromClauseJoinTables() { Hashtable tablePropertyAliases = null; foreach (ITableMap tableMap in this.tableAliases.Keys) { tablePropertyAliases = (Hashtable) this.tableAliases[tableMap]; foreach (string s in tablePropertyAliases.Values) { SqlTableAlias table = select.GetSqlTableAlias(tableMap, s); if (!(includedTableAliases.Contains(table))) { FromTable fromTable = new FromTable() ; fromTable.Alias = table; fromAliasTables.Add(fromTable); includedTableAliases.Add(table); } } } }
private void GetWhereClauseJoinTables(ArrayList tableJoins) { ReferenceType refType; foreach (TableJoin tableJoin in tableJoins) { refType = tableJoin.PropertyMap.ReferenceType; if (refType != ReferenceType.None) { CreateJoin(tableJoin); if (tableJoin.JoinType == JoinType.InnerJoin) { EmitOldStyleInnerJoin(tableJoin); } else { FromTable fromTable = new FromTable(); EmitLeftOuterJoin(tableJoin, fromTable); fromJoinTables.Add(fromTable); } } GetWhereClauseJoinTables(tableJoin.Children); } }