Ejemplo n.º 1
0
        public virtual void GetListPropertySubselectAndAlias(IPropertyMap propertyMap, object hash, Hashtable columns, ArrayList order, string propPath, string suggestion)
        {
            if (hash == null)
            {
                hash = propertyMap;
            }
            ITableMap     listTableMap   = propertyMap.MustGetTableMap();
            ITableMap     parentTableMap = propertyMap.ClassMap.MustGetTableMap();
            SqlTableAlias parentTable    = sqlEmitter.GetTableAlias(parentTableMap, hash);

            SqlSelectStatement subSelect = new SqlSelectStatement(parentTableMap.SourceMap);

            //Hmmm....can an alias be redefined in a subselect?
            //SqlTableAlias listTable = subSelect.GetSqlTableAlias(listTableMap, "cnt" + subSelect.GetNextTableAliasIndex());
            SqlTableAlias listTable = subSelect.GetSqlTableAlias(listTableMap, "cnt" + sqlEmitter.Select.GetNextTableAliasIndex());

            SqlCountFunction count = new SqlCountFunction();

            subSelect.SqlSelectClause.AddSqlAliasSelectListItem(count);

            subSelect.SqlFromClause.AddSqlAliasTableSource(listTable);

            foreach (IColumnMap fkIdColumnMap in propertyMap.GetAllIdColumnMaps())
            {
                IColumnMap idColumnMap = fkIdColumnMap.MustGetPrimaryKeyColumnMap();

                SqlColumnAlias     fkIdColumn = listTable.GetSqlColumnAlias(fkIdColumnMap);
                SqlColumnAlias     idColumn   = parentTable.GetSqlColumnAlias(idColumnMap);
                SqlSearchCondition search     = subSelect.SqlWhereClause.GetNextSqlSearchCondition();

                search.GetSqlComparePredicate(fkIdColumn, SqlCompareOperatorType.Equals, idColumn);
            }

            if (suggestion == "")
            {
                suggestion = propPath;
            }

            SqlAliasSelectListItem countAlias = this.sqlEmitter.Select.SqlSelectClause.AddSqlAliasSelectListItem(subSelect, suggestion);

            this.sqlEmitter.PropertyColumnMap[propPath] = countAlias.SqlExpressionAlias.Alias;
        }
Ejemplo n.º 2
0
 public virtual void Visited(SqlAliasSelectListItem aliasSelectListItem)
 {
     sqlBuilder.Append(", ");
 }
Ejemplo n.º 3
0
 public virtual void Visiting(SqlAliasSelectListItem aliasSelectListItem)
 {
     //
 }