private void SetGroupby(GroupbyContext groupby, string name, string varName)
 {
     if (groupby != null)
     {
         var                    dq              = new DataCube(name, DataStatement.GROUPBY, varName);
         FieldsContext          fields          = groupby.fields();
         FilterconditionContext Filtercondition = groupby.filtercondition();
         SortstatementContext   sortStatement   = groupby.sortstatement();
         AggContext             agg             = groupby.agg();
         if (fields != null)
         {
             string[] s = fields.GetText().Split(',');
             for (int i = 0; i < s.Length; i++)
             {
                 dq.GroupByStatement.AddField(new State.DataField(s[i], s[i]));
             }
         }
         if (agg != null)
         {
             string[] s = agg.GetText().Split(',');
             for (int i = 0; i < s.Length; i++)
             {
                 string[] f = s[i].Split('.');
                 var      a = new State.AggregateField(f[0], f[0])
                 {
                     AggregateType = f[1]
                 };
                 dq.GroupByStatement.AddAgg(a);
             }
         }
         if (Filtercondition != null)
         {
             ConditionContext condition = Filtercondition.condition();
             var search = new State.Search(condition.children[0].GetText(), condition.children[1].GetText(), condition.children[2].GetText());
             dq.SelectStatement.AddCondition(search);
         }
         if (sortStatement != null)
         {
             OrderContext order = sortStatement.order();
             dq.SelectStatement.AddOrder(new State.SortBy(order.ORDERBY()[0].GetText(), order.fields()[0].GetText()));
         }
         DataCubes.Add(dq);
     }
 }
Пример #2
0
 public GroupBy AddAgg(AggregateField agg)
 {
     this.AggregateFields.Add(agg);
     return(this);
 }