Esempio n. 1
0
		public override AstElement Clone(Dictionary<AstElement, AstElement> alreadyClonedElements)
		{
			TopClause result = new TopClause();
			result.Value = _value;
			result.WithTies = _withTies;
			return result;
		}
Esempio n. 2
0
        public override AstElement Clone(Dictionary <AstElement, AstElement> alreadyClonedElements)
        {
            TopClause result = new TopClause();

            result.Value    = _value;
            result.WithTies = _withTies;
            return(result);
        }
Esempio n. 3
0
        private QueryNode ParseSelectQuery()
        {
            if (_token.Id == TokenId.LeftParentheses)
            {
                NextToken();
                QueryNode result = ParseQuery();
                Match(TokenId.RightParentheses);
                return result;
            }

            if (!Match(TokenId.SELECT))
                return null;

            SelectQuery selectQuery = new SelectQuery();

            // DISTINCT

            if (_token.Id == TokenId.DISTINCT)
            {
                selectQuery.IsDistinct = true;
                NextToken();
            }

            // TOP

            if (_token.Id == TokenId.TOP)
            {
                NextToken();

                TopClause topClause = new TopClause();
                topClause.Value = (int)ParseInteger();

                if (_token.Id == TokenId.WITH)
                {
                    NextToken();
                    Match(TokenId.TIES);
                    topClause.WithTies = true;
                }
                selectQuery.TopClause = topClause;
            }

            // SelectColumns

            selectQuery.SelectColumns = ParseColumnSources();

            // FROM

            if (_token.Id == TokenId.FROM)
            {
                NextToken();
                selectQuery.TableReferences = ParseTableReferences();
            }

            // WHERE

            if (_token.Id == TokenId.WHERE)
            {
                NextToken();
                selectQuery.WhereClause = ParseExpression();
            }

            // GROUP BY

            if (_token.Id == TokenId.GROUP)
            {
                NextToken();
                Match(TokenId.BY);
                selectQuery.GroupByColumns = ParseExpressions();
            }

            // HAVING

            if (_token.Id == TokenId.HAVING)
            {
                NextToken();
                selectQuery.HavingClause = ParseExpression();
            }

            return selectQuery;
        }
Esempio n. 4
0
        private QueryNode ParseSelectQuery()
        {
            if (_token.Id == TokenId.LeftParentheses)
            {
                NextToken();
                QueryNode result = ParseQuery();
                Match(TokenId.RightParentheses);
                return(result);
            }

            if (!Match(TokenId.SELECT))
            {
                return(null);
            }

            SelectQuery selectQuery = new SelectQuery();

            // DISTINCT

            if (_token.Id == TokenId.DISTINCT)
            {
                selectQuery.IsDistinct = true;
                NextToken();
            }

            // TOP

            if (_token.Id == TokenId.TOP)
            {
                NextToken();

                TopClause topClause = new TopClause();
                topClause.Value = (int)ParseInteger();

                if (_token.Id == TokenId.WITH)
                {
                    NextToken();
                    Match(TokenId.TIES);
                    topClause.WithTies = true;
                }
                selectQuery.TopClause = topClause;
            }

            // SelectColumns

            selectQuery.SelectColumns = ParseColumnSources();

            // FROM

            if (_token.Id == TokenId.FROM)
            {
                NextToken();
                selectQuery.TableReferences = ParseTableReferences();
            }

            // WHERE

            if (_token.Id == TokenId.WHERE)
            {
                NextToken();
                selectQuery.WhereClause = ParseExpression();
            }

            // GROUP BY

            if (_token.Id == TokenId.GROUP)
            {
                NextToken();
                Match(TokenId.BY);
                selectQuery.GroupByColumns = ParseExpressions();
            }

            // HAVING

            if (_token.Id == TokenId.HAVING)
            {
                NextToken();
                selectQuery.HavingClause = ParseExpression();
            }

            return(selectQuery);
        }