Пример #1
0
        private SqlOrderBy AddOrderBy(Token[] tokens, ref int i, SqlQuery parent)
        {
            var section = new SqlOrderBy(parent);

            section.Sections.Add(new SqlSection(section, new SqlToken(true, tokens[i])));
            parent.Sections.Add(section);

            for (i++; i < tokens.Length; i++)
            {
                if (IsMatch(tokens, i, "GROUP", "BY"))
                {
                    AddOrderBy(tokens, ref i, parent);
                    break;
                }
                else if (tokens[i].Type == TokenType.EndOfQuery || tokens[i].Type == TokenType.EndParenthesis)
                {
                    AddTokenSection(parent, tokens[i]);
                    break;
                }
                else if (IsQueryStart(tokens[i]))
                {
                    i--;
                    break;
                }

                AddTokenSection(section, tokens[i]);
            }
            return(section);
        }
Пример #2
0
        private SqlOrderBy AddOrderBy(Token[] tokens, ref int i, SqlQuery parent)
        {
            var section = new SqlOrderBy(parent);
            section.Sections.Add(new SqlSection(section, new SqlToken(true, tokens[i])));
            parent.Sections.Add(section);

            for (i++; i < tokens.Length; i++)
            {
                if (IsMatch(tokens, i, "GROUP", "BY"))
                {
                    AddOrderBy(tokens, ref i, parent);
                    break;
                }
                else if (tokens[i].Type == TokenType.EndOfQuery || tokens[i].Type == TokenType.EndParenthesis)
                {
                    AddTokenSection(parent, tokens[i]);
                    break;
                }
                else if (IsQueryStart(tokens[i]))
                {
                    i--;
                    break;
                }

                AddTokenSection(section, tokens[i]);
            }
            return section;
        }