Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Visits the Linq Where method.
        /// </summary>
        /// <param name="expression">The expression.</param>
        protected virtual Expression VisitWhere(MethodCallExpression expression)
        {
            LambdaExpression lambda = (LambdaExpression)StripQuotes(expression.Arguments[1]);

            this.Visit(lambda.Body);

            SelectExpression.SetWhereExpression(new WhereExpression(LinqStringBuilder.ToString(), LinqParameters.GetParams()));
            LinqParameters.Clear();
            LinqStringBuilder = null;

            return(expression);
        }
Ejemplo n.º 4
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);
        }