Example #1
0
            internal override SqlRowNumber VisitRowNumber(SqlRowNumber rowNumber)
            {
                List <SqlOrderExpression> orderByList = new List <SqlOrderExpression>();

                foreach (SqlOrderExpression expression in rowNumber.OrderBy)
                {
                    orderByList.Add(new SqlOrderExpression(expression.OrderType, (SqlExpression)this.Visit(expression.Expression)));
                }
                return(new SqlRowNumber(rowNumber.ClrType, rowNumber.SqlType, orderByList, rowNumber.SourceExpression));
            }
Example #2
0
        internal virtual SqlRowNumber VisitRowNumber(SqlRowNumber rowNumber)
        {
            int num   = 0;
            int count = rowNumber.OrderBy.Count;

            while (num < count)
            {
                rowNumber.OrderBy[num].Expression = this.VisitExpression(rowNumber.OrderBy[num].Expression);
                num++;
            }
            return(rowNumber);
        }
Example #3
0
 internal override SqlRowNumber VisitRowNumber(SqlRowNumber rowNumber)
 {
     if (rowNumber.OrderBy.Count <= 0)
     {
         SqlDuplicator             duplicator = new SqlDuplicator(true);
         List <SqlOrderExpression> list       = new List <SqlOrderExpression>();
         List <SqlOrderExpression> list2      = new List <SqlOrderExpression>();
         if ((this.rowNumberOrders != null) && (this.rowNumberOrders.Count != 0))
         {
             list2 = new List <SqlOrderExpression>(this.rowNumberOrders);
         }
         else if (this.orders != null)
         {
             list2 = new List <SqlOrderExpression>(this.orders);
         }
         foreach (SqlOrderExpression expression in list2)
         {
             if (!expression.Expression.IsConstantColumn)
             {
                 list.Add(expression);
                 if (this.rowNumberOrders != null)
                 {
                     this.rowNumberOrders.Remove(expression);
                 }
                 if (this.orders != null)
                 {
                     this.orders.Remove(expression);
                 }
             }
         }
         rowNumber.OrderBy.Clear();
         if (list.Count == 0)
         {
             foreach (
                 SqlColumn column in
                 SqlReorderer.SqlGatherColumnsProduced.GatherColumns(this.currentSelect.From))
             {
                 if (column.Expression.SqlType.IsOrderable)
                 {
                     list.Add(new SqlOrderExpression(SqlOrderType.Ascending, new SqlColumnRef(column)));
                 }
             }
             if (list.Count == 0)
             {
                 var column2 = new SqlColumn("rowNumberOrder",
                                             sql.Value(typeof(int),
                                                       typeProvider.From(typeof(int)), 1,
                                                       false, rowNumber.SourceExpression));
                 this.PushDown(column2);
                 list.Add(new SqlOrderExpression(SqlOrderType.Ascending, new SqlColumnRef(column2)));
             }
         }
         foreach (SqlOrderExpression expression2 in list)
         {
             rowNumber.OrderBy.Add(new SqlOrderExpression(expression2.OrderType,
                                                          (SqlExpression)
                                                          duplicator.Duplicate(expression2.Expression)));
         }
     }
     return(rowNumber);
 }