internal override SqlSelect VisitSelect(SqlSelect select)
            {
                SqlSource            from = this.VisitSource(select.From);
                List <SqlExpression> gex  = null;

                if (select.GroupBy.Count > 0)
                {
                    gex = new List <SqlExpression>(select.GroupBy.Count);
                    foreach (SqlExpression sqlExpr in select.GroupBy)
                    {
                        gex.Add((SqlExpression)this.Visit(sqlExpr));
                    }
                }
                SqlExpression             having = (SqlExpression)this.Visit(select.Having);
                List <SqlOrderExpression> lex    = null;

                if (select.OrderBy.Count > 0)
                {
                    lex = new List <SqlOrderExpression>(select.OrderBy.Count);
                    foreach (SqlOrderExpression sox in select.OrderBy)
                    {
                        SqlOrderExpression nsox = new SqlOrderExpression(sox.OrderType, (SqlExpression)this.Visit(sox.Expression));
                        lex.Add(nsox);
                    }
                }
                SqlExpression top = (SqlExpression)this.Visit(select.Top);

                SqlExpression where = (SqlExpression)this.Visit(select.Where);
                SqlRow        row       = (SqlRow)this.Visit(select.Row);
                SqlExpression selection = this.VisitExpression(select.Selection);

                SqlSelect n = new SqlSelect(selection, from, select.SourceExpression);

                if (gex != null)
                {
                    n.GroupBy.AddRange(gex);
                }
                n.Having = having;
                if (lex != null)
                {
                    n.OrderBy.AddRange(lex);
                }
                n.OrderingType = select.OrderingType;
                n.Row          = row;
                n.Top          = top;
                n.IsDistinct   = select.IsDistinct;
                n.IsPercent    = select.IsPercent;
                n.Where        = where;
                n.DoNotOutput  = select.DoNotOutput;
                return(n);
            }
Example #2
0
            internal override SqlSelect VisitSelect(SqlSelect select)
            {
                SqlSource            from = VisitSource(select.From);
                List <SqlExpression> list = null;

                if (select.GroupBy.Count > 0)
                {
                    list = new List <SqlExpression>(select.GroupBy.Count);
                    foreach (var item2 in select.GroupBy)
                    {
                        list.Add((SqlExpression)Visit(item2));
                    }
                }
                var having = (SqlExpression)Visit(select.Having);
                List <SqlOrderExpression> list2 = null;

                if (select.OrderBy.Count > 0)
                {
                    list2 = new List <SqlOrderExpression>(select.OrderBy.Count);
                    foreach (var item3 in select.OrderBy)
                    {
                        var item = new SqlOrderExpression(item3.OrderType, (SqlExpression)Visit(item3.Expression));
                        list2.Add(item);
                    }
                }
                var top = (SqlExpression)Visit(select.Top);

                var where = (SqlExpression)Visit(select.Where);
                var           row       = (SqlRow)Visit(select.Row);
                SqlExpression selection = VisitExpression(select.Selection);
                var           sqlSelect = new SqlSelect(selection, from, select.SourceExpression);

                if (list != null)
                {
                    sqlSelect.GroupBy.AddRange(list);
                }
                sqlSelect.Having = having;
                if (list2 != null)
                {
                    sqlSelect.OrderBy.AddRange(list2);
                }
                sqlSelect.OrderingType = select.OrderingType;
                sqlSelect.Row          = row;
                sqlSelect.Top          = top;
                sqlSelect.IsDistinct   = select.IsDistinct;
                sqlSelect.IsPercent    = select.IsPercent;
                sqlSelect.Where        = where;
                sqlSelect.DoNotOutput  = select.DoNotOutput;
                return(sqlSelect);
            }