Esempio n. 1
0
        /// <summary>
        /// Visits the Linq aggregate methods.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="aggregateName">Name of aggreage method.</param>
        protected virtual Expression VisitAggregate(MethodCallExpression expression, string aggregateName)
        {
            LinqStringBuilder.Append($"{aggregateName}(");
            this.Visit(StripQuotes(expression.Arguments[1]));
            LinqStringBuilder.Append(")");

            SelectExpression.SetColumnsExpression(new ColumnsExpression(LinqStringBuilder.ToString()));
            LinqStringBuilder.Clear();

            return(expression);
        }
Esempio n. 2
0
        private Expression VisitOrderBy(MethodCallExpression expression, OrderType orderType)
        {
            var lambda = (LambdaExpression)StripQuotes(expression.Arguments[1]);

            var ret = Visit(lambda);

            Orders.Add(LinqStringBuilder.ToString() + " " + (orderType == OrderType.Ascending ? "ASC" : "DESC"));
            LinqStringBuilder.Clear();

            return(ret);
        }
Esempio n. 3
0
        private Expression VisitOrderBy(MethodCallExpression expression, OrderType orderType)
        {
            var lambda = (LambdaExpression)StripQuotes(expression.Arguments[1]);

            var ret = this.Visit(lambda);

            _orders.Add(new OrderBy()
            {
                ColumnaName = LinqStringBuilder.ToString(), Type = orderType
            });
            LinqStringBuilder.Clear();

            return(ret);
        }
Esempio n. 4
0
        /// <summary>
        /// Visits the Linq Take method.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <exception cref="System.NotSupportedException">If call of Take method is not supported.</exception>
        protected virtual Expression VisitTake(MethodCallExpression expression)
        {
            this.Visit(StripQuotes(expression.Arguments[1]));
            LinqStringBuilder.Clear();

            try
            {
                _top = (int)LinqParameters.GetParams().First();

                LinqParameters = new Parameters();
                return(expression);
            }
            catch (Exception e)
            {
                throw new NotSupportedException("This call of Take method is not supported", e);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Visits the Linq Take method.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <exception cref="System.NotSupportedException">If call of Take method is not supported.</exception>
        protected virtual Expression VisitTake(MethodCallExpression expression)
        {
            Visit(StripQuotes(expression.Arguments[1]));
            LinqStringBuilder.Clear();

            try
            {
                _top = (int)LinqParameters.GetParams().First();

                LinqParameters = new Parameters();
                return(expression);
            }
            catch (Exception ex)
            {
                throw new NotSupportedException(Resources.ThisCallOfTakeMethodIsNotSupported, ex);
            }
        }