internal override string ToString(string indent)
        {
            StringBuilder sb = new StringBuilder(128);

            sb.AppendFormat("{0}DELETE NODE", indent);
            if (TopRowFilter != null)
            {
                if (TopRowFilter.OneLine())
                {
                    sb.Append(TopRowFilter.ToString(""));
                }
                else
                {
                    sb.Append("\r\n");
                    sb.Append(TopRowFilter.ToString(indent + "  "));
                }
            }
            sb.AppendFormat(" FROM {0}", Target.ToString());

            if (FromClause != null)
            {
                sb.Append("\r\n");
                sb.Append(FromClause.ToString(indent));
            }

            if (WhereClause != null && WhereClause.SearchCondition != null)
            {
                sb.Append("\r\n");
                sb.Append(WhereClause.ToString(indent));
            }

            return(sb.ToString());
        }
        public void TopRowFilterTest()
        {
            var empties = _board.Values.Where(v => v.Content == ContentType.Empty).ToArray();

            var rule = new TopRowFilter();

            Assert.AreEqual("is in TOP ROW ", rule.ToString());

            var matches = rule.GetMatches(_board, empties);

            CollectionAssert.AreEquivalent(new[] { 8, 3, 4 }, matches.ToArray());
        }
        internal override string ToString(string indent)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("{0}UPDATE", indent);
            if (TopRowFilter != null)
            {
                sb.Append(TopRowFilter.ToString(indent));
            }

            sb.AppendFormat(" {0} SET \r\n", Target.ToString(indent));

            var first = true;

            if (SetClauses != null)
            {
                foreach (var setclause in SetClauses)
                {
                    if (first)
                    {
                        first = false;
                        sb.AppendFormat("{0}{1}", indent, setclause.ToString(indent));
                    }
                    else
                    {
                        sb.AppendFormat(", {0}", setclause.ToString(indent));
                    }
                }
            }

            if (FromClause != null)
            {
                sb.AppendFormat("\r\n{0}{1}", indent, FromClause.ToString(indent));
            }
            if (WhereClause != null && WhereClause.SearchCondition != null)
            {
                sb.AppendFormat("\r\n{0}{1}", indent, WhereClause.ToString(indent));
            }
            sb.Append("\r\n");
            return(sb.ToString());
        }
        internal override string ToString(string indent)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("{0}DELETE ", indent);
            if (TopRowFilter != null)
            {
                sb.Append(TopRowFilter.ToString(indent));
            }

            sb.AppendFormat(" FROM {0} ", Target.ToString(indent));

            if (FromClause != null)
            {
                sb.Append(FromClause.ToString(indent));
            }

            if (WhereClause != null && WhereClause.SearchCondition != null)
            {
                sb.Append(WhereClause.ToString(indent));
            }

            return(sb.ToString());
        }
示例#5
0
        internal override string ToString(string indent)
        {
            var sb = new StringBuilder(1024);

            if (WithPathClause2 != null)
            {
                sb.Append(WithPathClause2.ToString(indent));
            }

            sb.AppendFormat("{0}SELECT ", indent);

            if (TopRowFilter != null)
            {
                if (TopRowFilter.OneLine())
                {
                    sb.AppendFormat("{0} ", TopRowFilter.ToString(""));
                }
                else
                {
                    sb.Append("\r\n");
                    sb.AppendFormat("{0} ", TopRowFilter.ToString(indent));
                }
            }

            switch (UniqueRowFilter)
            {
            case UniqueRowFilter.All:
                sb.Append("ALL ");
                break;

            case UniqueRowFilter.Distinct:
                sb.Append("DISTINCT ");
                break;
            }

            for (var i = 0; i < SelectElements.Count; i++)
            {
                if (i > 0)
                {
                    sb.Append(", ");
                }

                if (SelectElements[i].OneLine())
                {
                    sb.Append(SelectElements[i].ToString(""));
                }
                else
                {
                    sb.Append("\r\n");
                    sb.Append(SelectElements[i].ToString(indent + " "));
                }
            }

            if (Into != null)
            {
                sb.AppendFormat(" INTO {0} ", Into);
            }

            if (FromClause != null)
            {
                sb.Append("\r\n");
                sb.Append(FromClause.ToString(indent));
            }

            if (MatchClause != null)
            {
                sb.Append("\r\n");
                sb.Append(MatchClause.ToString(indent));
            }

            if (WhereClause != null && (WhereClause.SearchCondition != null || !string.IsNullOrEmpty(WhereClause.GhostString)))
            {
                sb.Append("\r\n");
                sb.Append(WhereClause.ToString(indent));
            }

            if (GroupByClause != null)
            {
                sb.Append("\r\n");
                sb.Append(GroupByClause.ToString(indent));
            }

            if (HavingClause != null)
            {
                sb.Append("\r\n");
                sb.Append(HavingClause.ToString(indent));
            }

            if (OrderByClause != null)
            {
                sb.Append("\r\n");
                sb.Append(OrderByClause.ToString(indent));
            }

            return(sb.ToString());
        }