예제 #1
0
 protected override Expression VisitSelect(SelectExpression select)
 {
     select = (SelectExpression)base.VisitSelect(select);
     if (select.Skip != null)
     {
         Expression       expression3;
         SelectExpression sel = select.SetSkip(null).SetTake(null);
         if (select.IsDistinct || ((select.GroupBy != null) && (select.GroupBy.Count != 0)))
         {
             sel = sel.AddRedundantSelect(this.language, new TableAlias());
         }
         QueryType columnType = this.language.TypeSystem.GetColumnType(typeof(int));
         sel = sel.AddColumn(new ColumnDeclaration("row__num", new RowNumberExpression(select.OrderBy), columnType)).AddRedundantSelect(this.language, new TableAlias());
         sel = sel.RemoveColumn(sel.Columns.Single <ColumnDeclaration>(c => c.Name == "row__num"));
         TableAlias       alias      = ((SelectExpression)sel.From).Alias;
         ColumnExpression expression = new ColumnExpression(typeof(int), columnType, alias, "row__num");
         if (select.Take != null)
         {
             expression3 = new BetweenExpression(expression, Expression.Add(select.Skip, Expression.Constant(1)), Expression.Add(select.Skip, select.Take));
         }
         else
         {
             expression3 = expression.GreaterThan(select.Skip);
         }
         if (sel.Where != null)
         {
             expression3 = sel.Where.And(expression3);
         }
         select = sel.SetWhere(expression3);
     }
     return(select);
 }
예제 #2
0
 protected BetweenExpression UpdateBetween(BetweenExpression between, Expression expression, Expression lower, Expression upper)
 {
     if (((expression != between.Expression) || (lower != between.Lower)) || (upper != between.Upper))
     {
         return(new BetweenExpression(expression, lower, upper));
     }
     return(between);
 }
예제 #3
0
        protected virtual Expression VisitBetween(BetweenExpression between)
        {
            Expression expression = this.Visit(between.Expression);
            Expression lower      = this.Visit(between.Lower);
            Expression upper      = this.Visit(between.Upper);

            return(this.UpdateBetween(between, expression, lower, upper));
        }
예제 #4
0
 protected override Expression VisitBetween(BetweenExpression between)
 {
     this.VisitValue(between.Expression);
     this.Write(" BETWEEN ");
     this.VisitValue(between.Lower);
     this.Write(" AND ");
     this.VisitValue(between.Upper);
     return(between);
 }
 protected virtual bool CompareBetween(BetweenExpression a, BetweenExpression b)
 {
     return((this.Compare(a.Expression, b.Expression) && this.Compare(a.Lower, b.Lower)) && this.Compare(a.Upper, b.Upper));
 }