Exemplo n.º 1
0
        public static string ToString(LogicalClause clause)
        {
            var visitor = new SnQueryToStringVisitor();

            visitor.VisitLogicalClause(clause);
            return(visitor.Output);
        }
Exemplo n.º 2
0
        public static string ToString(LogicalPredicate predicate)
        {
            var visitor = new SnQueryToStringVisitor();

            visitor.VisitLogicalPredicate(predicate);
            return(visitor.Output);
        }
Exemplo n.º 3
0
        public static string ToString(List <LogicalClause> clauses)
        {
            var visitor = new SnQueryToStringVisitor();

            visitor.VisitLogicalClauses(clauses);
            return(visitor.Output);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns with string representation of the query.
        /// Contains the whole CQL query with predicates and extensions.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var visitor = new SnQueryToStringVisitor();

            visitor.Visit(QueryTree);
            var sb = new StringBuilder(visitor.Output);

            if (AllVersions)
            {
                sb.Append(" ").Append(Cql.Keyword.AllVersions);
            }
            if (CountOnly)
            {
                sb.Append(" ").Append(Cql.Keyword.CountOnly);
            }
            if (Top != 0 && Top != int.MaxValue)
            {
                sb.Append(" ").Append(Cql.Keyword.Top).Append(":").Append(Top);
            }
            if (Skip != 0)
            {
                sb.Append(" ").Append(Cql.Keyword.Skip).Append(":").Append(Skip);
            }
            if (HasSort)
            {
                foreach (var sortInfo in Sort)
                {
                    if (sortInfo.Reverse)
                    {
                        sb.Append(" ").Append(Cql.Keyword.ReverseSort).Append(":").Append(sortInfo.FieldName);
                    }
                    else
                    {
                        sb.Append(" ").Append(Cql.Keyword.Sort).Append(":").Append(sortInfo.FieldName);
                    }
                }
            }
            if (EnableAutofilters != FilterStatus.Default && EnableAutofilters != EnableAutofiltersDefaultValue)
            {
                sb.Append(" ").Append(Cql.Keyword.Autofilters).Append(":").Append(EnableAutofiltersDefaultValue == FilterStatus.Enabled ? Cql.Keyword.Off : Cql.Keyword.On);
            }
            if (EnableLifespanFilter != FilterStatus.Default && EnableLifespanFilter != EnableLifespanFilterDefaultValue)
            {
                sb.Append(" ").Append(Cql.Keyword.Lifespan).Append(":").Append(EnableLifespanFilterDefaultValue == FilterStatus.Enabled ? Cql.Keyword.Off : Cql.Keyword.On);
            }
            if (QueryExecutionMode == QueryExecutionMode.Quick)
            {
                sb.Append(" ").Append(Cql.Keyword.Quick);
            }

            return(sb.ToString());
        }