Tup.Cobar4Net.Parser.Ast.Stmt.Dml.DmlSelectUnionStatement.AddSelect C# (CSharp) Method

AddSelect() public method

public AddSelect ( DmlSelectStatement select, bool unionAll ) : DmlSelectUnionStatement
select DmlSelectStatement
unionAll bool
return DmlSelectUnionStatement
        public virtual DmlSelectUnionStatement AddSelect(DmlSelectStatement select, bool unionAll)
        {
            selectStmtList.Add(select);
            if (!unionAll)
            {
                firstDistinctIndex = selectStmtList.Count - 1;
            }
            return this;
        }

Usage Example

Esempio n. 1
0
        /// <returns>argument itself if there is no union</returns>
        /// <exception cref="System.SqlSyntaxErrorException" />
        protected virtual DmlQueryStatement BuildUnionSelect(DmlSelectStatement select)
        {
            if (lexer.Token() != MySqlToken.KwUnion)
            {
                return select;
            }
            var union = new DmlSelectUnionStatement(select);
            for (; lexer.Token() == MySqlToken.KwUnion;)
            {
                lexer.NextToken();
                var isAll = false;
                switch (lexer.Token())
                {
                    case MySqlToken.KwAll:
                    {
                        isAll = true;
                        goto case MySqlToken.KwDistinct;
                    }

                    case MySqlToken.KwDistinct:
                    {
                        lexer.NextToken();
                        break;
                    }
                }
                select = SelectPrimary();
                union.AddSelect(select, isAll);
            }
            union.SetOrderBy(OrderBy()).SetLimit(Limit());
            return union;
        }