Ejemplo n.º 1
0
        public override void Accept(TSqlFragmentVisitor visitor)
        {
            visitor.ExplicitVisit(this);
            TopRowFilter?.Accept(visitor);

            foreach (var element in SelectElements)
            {
                element.Accept(visitor);
            }

            FromClause?.Accept(visitor);
            OffsetClause?.Accept(visitor);
            WhereClause?.Accept(visitor);
            GroupByClause?.Accept(visitor);
            OrderByClause?.Accept(visitor);
        }
Ejemplo n.º 2
0
        public override void ToString(StringBuilder buf, int indent)
        {
            buf.Append(' ', indent);

            var longestClause = "SELECT";

            if (GroupByClause != null)
            {
                longestClause = "GROUP BY";
            }
            else if (OrderByClause != null)
            {
                longestClause = "ORDER BY";
            }

            buf.Append("SELECT");

            buf.Append(' ', longestClause.Length - "SELECT".Length + 1);

            if (UniqueRowFilter == UniqueRowFilter.Distinct)
            {
                buf.Append("DISTINCT ");
            }

            TopRowFilter?.ToString(buf, indent);

            var selectIndent = Sql150ScriptGenerator.GetCurrentIndent(buf);

            for (var i = 0; i < SelectElements.Count; i++)
            {
                if (i > 0)
                {
                    buf.Append(",\r\n");
                    buf.Append(' ', selectIndent);
                }

                SelectElements[i].ToString(buf, selectIndent);
            }

            buf.Append("\r\n");

            FromClause?.ToString(buf, indent, longestClause.Length);
            WhereClause?.ToString(buf, indent, longestClause.Length);
            GroupByClause?.ToString(buf, indent, longestClause.Length);
            OrderByClause?.ToString(buf, indent, longestClause.Length);
            OffsetClause?.ToString(buf, indent, longestClause.Length);
        }
        /// <summary>
        /// GropuBy句 にコンストラクタで指定された集計キーを追加する。
        /// </summary>
        /// <param name="node">GroupBy句</param>
        public override void ExplicitVisit(Microsoft.SqlServer.TransactSql.ScriptDom.GroupByClause node)
        {
            try
            {
                var groupingSpecifications = FindGroupingSpecifications.Compile().Invoke(node);
                if (groupingSpecifications == null)
                {
                    groupingSpecifications = new List <GroupingSpecification>();
                }
                groupingSpecifications.Add(GroupingSpecification);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("指定された条件式は追加できません。", e);
            }

            base.ExplicitVisit(node);
        }
Ejemplo n.º 4
0
 public GroupByClause(ScriptDom.GroupByClause src) : base(src)
 {
     this.GroupByOption = src.GroupByOption;
     this.All           = src.All;
     Copier.CopyList(this.GroupingSpecifications, src.GroupingSpecifications);
 }
Ejemplo n.º 5
0
 public virtual void ExplicitVisit(GroupByClause groupByClause)
 {
 }