コード例 #1
0
        private void ResolveColumnRefernecesInUnionOrderBy()
        {
            int orderLength = this.ExprSortAndSlice.GetOrderLength();

            if (orderLength != 0)
            {
                string[] columnNames = this.GetColumnNames();
                int      num2        = 0;
                while (num2 < orderLength)
                {
                    ExpressionOrderBy by       = this.ExprSortAndSlice.ExprList[num2];
                    Expression        leftNode = by.GetLeftNode();
                    if (leftNode.GetExprType() == 1)
                    {
                        if (leftNode.GetDataType().TypeCode != 4)
                        {
                            goto Label_00B0;
                        }
                        int num3 = Convert.ToInt32(leftNode.GetValue(null));
                        if ((0 >= num3) || (num3 > columnNames.Length))
                        {
                            goto Label_00B0;
                        }
                        by.GetLeftNode().QueryTableColumnIndex = num3 - 1;
                    }
                    else
                    {
                        if (leftNode.GetExprType() != 2)
                        {
                            goto Label_00B0;
                        }
                        int num4 = ArrayUtil.Find(columnNames, leftNode.GetColumnName());
                        if (num4 < 0)
                        {
                            goto Label_00B0;
                        }
                        by.GetLeftNode().QueryTableColumnIndex = num4;
                    }
                    num2++;
                    continue;
Label_00B0:
                    throw Error.GetError(0x15c8);
                }
                this.ExprSortAndSlice.Prepare(null);
            }
        }
コード例 #2
0
ファイル: SortAndSlice.cs プロジェクト: cwdotson/FwNs
 public void Prepare(QuerySpecification select)
 {
     this.ColumnCount = this.ExprList.Count;
     if (this.ColumnCount != 0)
     {
         this.SortOrder      = new int[this.ColumnCount];
         this.SortDescending = new bool[this.ColumnCount];
         this.SortNullsLast  = new bool[this.ColumnCount];
         for (int i = 0; i < this.ColumnCount; i++)
         {
             ExpressionOrderBy by = this.ExprList[i];
             if (by.GetLeftNode().QueryTableColumnIndex == -1)
             {
                 this.SortOrder[i] = select.IndexStartOrderBy + i;
             }
             else
             {
                 this.SortOrder[i] = by.GetLeftNode().QueryTableColumnIndex;
             }
             this.SortDescending[i] = by.IsDescending();
             this.SortNullsLast[i]  = by.IsNullsLast();
             this.HasNullsLast     |= this.SortNullsLast[i];
         }
         if (((select != null) && !this.HasNullsLast) && (!select.IsDistinctSelect && !(select.IsGrouped | select.IsAggregated)))
         {
             int[] numArray = new int[this.ColumnCount];
             for (int j = 0; j < this.ColumnCount; j++)
             {
                 Expression leftNode = this.ExprList[j].GetLeftNode();
                 if (leftNode.GetExprType() != 2)
                 {
                     return;
                 }
                 if (leftNode.GetRangeVariable() != select.RangeVariables[0])
                 {
                     return;
                 }
                 numArray[j] = leftNode.ColumnIndex;
             }
             this._columnIndexes = numArray;
         }
     }
 }