Пример #1
0
        //// <summary> Gets the top most accessed property from the expression. For example `(X a) => a.B.C.D` will return descriptor of the property `D`. </summary>
        public static PropertyReference FromLambda <T>(LE.Expression <Func <T, object> > expr)
        {
            var b = expr.Body;

            while (b is LE.UnaryExpression uExpr && uExpr.NodeType == LE.ExpressionType.Convert)
            {
                b = uExpr.Operand;
            }

            switch (b)
            {
            case LE.MemberExpression memberExpr:
                if (memberExpr.Member is R.PropertyInfo prop)
                {
                    return(FromReflection(prop));
                }
                else
                {
                    throw new NotSupportedException($"Can't get property reference from member {memberExpr.Member}");
                }

            default:
                throw new NotSupportedException($"Can't get property reference from expression {b}");
            }
        }
Пример #2
0
        /// <summary>
        /// Execute an aggregation query.
        /// </summary>
        /// <typeparam name="K"></typeparam>
        /// <param name="keySelector">A Lambda expression which represents an accessor property of the field which shoule be aggregated.</param>
        /// <param name="aggregateType">One of the <see cref="AggregateType">AggregateType</see> enum members.</param>
        /// <returns>A single value, which represents the aggregate</returns>
        /// <remarks>Before using this function, make shure, that your database product supports the aggregate function, as defined in aggregateType.
        /// Polymorphy: StDev and Var only return the aggregate for the given class. All others return the aggregate for all subclasses.
        /// Transactions: Please note, that the aggregate functions always work against the database.
        /// Unsaved changes in your objects are not recognized.</remarks>
        public object ExecuteAggregate <K>(LE.Expression <Func <T, K> > keySelector, AggregateType aggregateType)
        {
            ExpressionTreeTransformer transformer =
                new ExpressionTreeTransformer(keySelector);
            string field = transformer.Transform();

            return(ExecuteAggregate(field, aggregateType));
        }
Пример #3
0
 /// <summary> Gets the top most invoked method from the expression. For example `(String a) => a.Trim(anything)` will return descriptor of the Trim method. The function also supports properties (it will return the getter) and constuctors (using the `new XXX()` syntax). </summary>
 public static MethodReference FromLambda(LE.Expression <Action> expr) => FromLambda(expr.Body);
Пример #4
0
        //---------------------------------------------------------------------
        public override void Emit()
        {
            LE.Expression expression = this.Tree.Accept(this);

            this.Result = LE.Expression.Lambda <Func <double[], double> >(expression, _arrayParameter);
        }
Пример #5
0
 /// <summary> Gets the top most invoked method from the expression. For example `(String a) => a.Trim(anything)` will return descriptor of the Trim method. The function also supports properties (it will return the getter) and constuctors (using the `new XXX()` syntax). </summary>
 public static MethodReference FromLambda(LE.Expression <Func <object> > expr) => FromLambda(expr.Body);