Пример #1
0
    protected override Expression BuildExpressionInternal(BuildExpressionContext context)
    {
        Expression baseExpression = parent.BuildExpression(context);

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

        return(result.BuildLite());
    }
Пример #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());
    }
Пример #3
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());
    }
Пример #4
0
    protected override Expression BuildExpressionInternal(BuildExpressionContext context)
    {
        var exp = parent.BuildExpression(context);

        var ut = parent.Type.UnNullify();

        var mi =
            ut == typeof(DateTime) ? GetMethodInfoDateTime(this.Name) :
            ut == typeof(DateOnly) ? GetMethodInfoDateOnly(this.Name) :
            ut == typeof(TimeOnly) ? GetMethodInfoTimeOnly(this.Name) :
            ut == typeof(TimeSpan) ? GetMethodInfoTimeSpan(this.Name) :
            throw new UnexpectedValueException(ut);

        return(Expression.Call(mi, exp.UnNullify()).Nullify());
    }
Пример #5
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));
    }
Пример #6
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.Nullify());
    }
Пример #7
0
 public Expression <Func <object, V> > GetLambdaExpression <V>(QueryToken token)
 {
     return(Expression.Lambda <Func <object, V> >(Expression.Convert(token.BuildExpression(Context), typeof(V)), Context.Parameter));
 }
Пример #8
0
    protected override Expression BuildExpressionInternal(BuildExpressionContext context)
    {
        var baseExpression = parent.BuildExpression(context);

        return(Expression.Call(baseExpression, miToString));
    }
Пример #9
0
    protected override Expression BuildExpressionInternal(BuildExpressionContext context)
    {
        var exp = parent.BuildExpression(context);

        return(RoundingExpressionGenerator.RoundExpression(exp, this.StepSize, RoundingType.Ceil));
    }
Пример #10
0
    protected override Expression BuildExpressionInternal(BuildExpressionContext context)
    {
        var exp = parent.BuildExpression(context);

        return(Expression.Modulo(Expression.Convert(exp, typeof(int)), Expression.Constant(Divisor)).Nullify());
    }
Пример #11
0
    protected override Expression BuildExpressionInternal(BuildExpressionContext context)
    {
        var exp = parent.BuildExpression(context);

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