Exemplo n.º 1
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            var exp = parent.BuildExpression(context);
            var mi  = GetMethodInfo(this.Name);

            return(Expression.Call(mi, exp.UnNullify()).Nullify());
        }
Exemplo n.º 2
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            var parentResult = parent.BuildExpression(context);

            var result = Expression.Call(miCount.MakeGenericMethod(parentResult.Type.ElementType()), parentResult);

            return(result.Nullify());
        }
Exemplo n.º 3
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            Expression baseExpression = parent.BuildExpression(context);

            Expression result = Expression.TypeAs(baseExpression.ExtractEntity(false), entityType);

            return(result.BuildLite());
        }
Exemplo n.º 4
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            var exp = parent.BuildExpression(context);
            var mi  = parent.Type.UnNullify() == typeof(Date) ?
                      GetMethodInfoDate(this.Name) :
                      GetMethodInfoDateTime(this.Name);

            return(Expression.Call(mi, exp.UnNullify()).Nullify());
        }
Exemplo n.º 5
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            var result = parent.BuildExpression(context);

            var prop =
                MemberInfo is PropertyInfo pi ? (Expression)Expression.Property(result.UnNullify(), pi) :
                MemberInfo is MethodInfo mi ? (mi.IsStatic ? Expression.Call(null, mi, result.UnNullify()) : Expression.Call(result.UnNullify(), mi)) :
                throw new UnexpectedValueException(MemberInfo);

            return(Expression.Call(miInSql.MakeGenericMethod(prop.Type), prop).Nullify());
        }
Exemplo n.º 6
0
        public static LambdaExpression CreateOrderLambda(QueryToken token, BuildExpressionContext ctx)
        {
            var body    = token.BuildExpression(ctx);
            var adapter = QueryUtils.OrderAdapters.TryGetC(token.Type);

            if (adapter != null)
            {
                body = adapter(body);
            }

            return(Expression.Lambda(body, ctx.Parameter));
        }
Exemplo n.º 7
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            Expression baseExpression = parent.BuildExpression(context);

            var result = Expression.NotEqual(baseExpression, Expression.Constant(null, baseExpression.Type.Nullify()));

            if (baseExpression.Type == typeof(string))
            {
                result = Expression.And(result, Expression.NotEqual(baseExpression, Expression.Constant("")));
            }

            return(result);
        }
Exemplo n.º 8
0
        public static LambdaExpression CreateOrderLambda(QueryToken token, BuildExpressionContext ctx)
        {
            foreach (var ad in OrderAdapters)
            {
                var func = ad(token);
                if (func != null)
                {
                    var b = func(ctx);
                    return(Expression.Lambda(b, ctx.Parameter));
                }
            }

            var body = token.BuildExpression(ctx);

            return(Expression.Lambda(body, ctx.Parameter));
        }
Exemplo n.º 9
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            Expression baseExpression = parent.BuildExpression(context);

            if (IsCollection(this.Parent !.Type))
            {
                var miGen = baseExpression.Type.IsInstantiationOf(typeof(IQueryable <>)) ? miAnyQ : miAnyE;
                return(Expression.Call(miGen.MakeGenericMethod(baseExpression.Type.ElementType() !), baseExpression));
            }

            var result = Expression.NotEqual(baseExpression, Expression.Constant(null, baseExpression.Type.Nullify()));

            if (baseExpression.Type == typeof(string))
            {
                result = Expression.And(result, Expression.NotEqual(baseExpression, Expression.Constant("")));
            }

            return(result);
        }
Exemplo n.º 10
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            var baseExpression = parent.BuildExpression(context);

            return(Expression.Call(baseExpression, miToString));
        }
Exemplo n.º 11
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            var exp = parent.BuildExpression(context);

            return(RoundingExpressionGenerator.RoundExpression(exp, this.StepSize, RoundingType.Ceil));
        }
Exemplo n.º 12
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            var exp = parent.BuildExpression(context);

            return(Expression.Modulo(Expression.Convert(exp, typeof(int)), Expression.Constant(Divisor)).Nullify());
        }
Exemplo n.º 13
0
        protected override Expression BuildExpressionInternal(BuildExpressionContext context)
        {
            var exp = parent.BuildExpression(context);

            return(Expression.Property(exp.UnNullify(), miDate).Nullify());
        }