Exemplo n.º 1
0
                protected static DbLimitExpression MinimumLimit(DbExpression input, DbLimitExpression limit, DbExpression k)
                {
                    // source.Limit(k).Limit(k2) -> source.Limit(Min(k, k2))
                    var newCount = CombineIntegers(limit.Limit, k, Math.Min);

                    return(input.Limit(newCount));
                }
Exemplo n.º 2
0
                protected static DbLimitExpression SubtractFromLimit(DbExpression input, DbLimitExpression limit, DbExpression minusK)
                {
                    var newCount = CombineIntegers(
                        limit.Limit, minusK,
                        (l, r) => r > l ? 0 : l - r); // can't limit to less than zero rows)

                    return(input.Limit(newCount));
                }
        private DbExpression RewriteLimitExpression(DbLimitExpression expression)
        {
            DbExpression dbExpression = this.Rewrite(expression.Argument);

            if (!object.ReferenceEquals((object)expression.Argument, (object)dbExpression))
            {
                expression = dbExpression.Limit(expression.Limit);
            }
            return((DbExpression)expression);
        }
Exemplo n.º 4
0
        private DbExpression RewriteLimitExpression(DbLimitExpression expression)
        {
            DbExpression rewrittenInput = Rewrite(expression.Argument);

            if (!object.ReferenceEquals(expression.Argument, rewrittenInput))
            {
                // Note that here we use the original expression.Limit. It is safe to do so,
                //  because we only allow physical paging (i.e. Limit can only be a constant or parameter)
                expression = rewrittenInput.Limit(expression.Limit);
            }
            return(expression);
        }
Exemplo n.º 5
0
 protected static DbLimitExpression MinimumLimit(DbExpression input, DbLimitExpression limit, DbExpression k)
 {
     // source.Limit(k).Limit(k2) -> source.Limit(Min(k, k2))
     var newCount = CombineIntegers(limit.Limit, k, Math.Min);
     return input.Limit(newCount);
 }
Exemplo n.º 6
0
 protected static DbLimitExpression SubtractFromLimit(DbExpression input, DbLimitExpression limit, DbExpression minusK)
 {
     var newCount = CombineIntegers(
         limit.Limit, minusK,
         (l, r) => r > l ? 0 : l - r); // can't limit to less than zero rows)
     return input.Limit(newCount);
 }