public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilters)
        {
            var loc = position * GetHashCode();
            var val = _projection.ToSqlString(criteria, loc, criteriaQuery, enabledFilters);

            val = HierarchyIdStringHelper.RemoveAsAliasesFromSql(val);

            var ret = new SqlStringBuilder()
                      .Add(val)
                      .Add(".GetLevel()")
                      .Add(" as ")
                      .Add(GetColumnAliases(position)[0])
                      .ToSqlString();

            return(ret);
        }
        public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilters)
        {
            var loc = position * GetHashCode();
            var val = _projection.ToSqlString(criteria, loc, criteriaQuery, enabledFilters);

            val = HierarchyIdStringHelper.RemoveAsAliasesFromSql(val);

            var lhs = new SqlStringBuilder();

            lhs.Add(val);
            lhs.Add(".GetAncestor(");
            lhs.Add(criteriaQuery.NewQueryParameter(new TypedValue(NHibernateUtil.Int32, _level, EntityMode.Poco)).Single());
            lhs.Add(") as ");
            lhs.Add(GetColumnAliases(position)[0]);

            var ret = lhs.ToSqlString();

            return(ret);
        }