Ejemplo n.º 1
0
        private IOperand getFieldRefOperand(LambdaExpression expr)
        {
            var body = expr.Body as MethodCallExpression;

            if (body.Arguments.Count == 1)
            {
                // generic list method
                return(operandBuilder.CreateFieldRefOperand(body.Arguments[0], null));
            }
            // linq extension method
            return(operandBuilder.CreateFieldRefOperand(body.Arguments[1], null));
        }
        //private bool isExpressionBasedOnCustomTypes(Expression objectExpression)
        //{
        //    return (objectExpression.NodeType == ExpressionType.Convert &&
        //        objectExpression.Type.IsSubclassOf(typeof(BaseFieldType)));
        //}

        //-----------------------------------

        protected IOperand getFieldRefOperand(LambdaExpression expr)
        {
            if (!IsValid(expr))
            {
                throw new NonSupportedExpressionException(expr);
            }
            var body = expr.Body as MethodCallExpression;

            return(operandBuilder.CreateFieldRefOperand(body.Object, null));
        }
Ejemplo n.º 3
0
        private IOperand getFieldRefOperand(LambdaExpression expr)
        {
            var body           = expr.Body as MethodCallExpression;
            var leftExpression = body.Arguments[0] as MethodCallExpression;

            if (leftExpression.Method.Name == ReflectionHelper.PrimaryListMethodName)
            {
                // both primary and foreign lists are specified
                return(operandBuilder.CreateFieldRefOperandForJoin(leftExpression.Arguments[0], leftExpression.Arguments[1]));
            }

            // only foreign list is specified
            var fieldRef = (FieldRefOperand)operandBuilder.CreateFieldRefOperand(body.Arguments[0], null);

            fieldRef.Attributes = new List <KeyValuePair <string, string> >(new[] { new KeyValuePair <string, string>(Attributes.RefType, Values.Id) });
            return(fieldRef);
        }
Ejemplo n.º 4
0
        //private bool isExpressionBasedOnCustomTypes(Expression objectExpression)
        //{
        //    return (objectExpression.NodeType == ExpressionType.Convert &&
        //        objectExpression.Type.IsSubclassOf(typeof(BaseFieldType)));
        //}

        //-----------------------------------

        protected virtual IOperand getFieldRefOperand(LambdaExpression expr)
        {
            if (!IsValid(expr))
            {
                throw new NonSupportedExpressionException(expr);
            }

            var obj = this.getObjectExpression(expr);

            IOperand valueOperand = null;
            var      body         = expr.Body as MethodCallExpression;

            if (body.Method.Name == ReflectionHelper.IncludesMethodName && body.Arguments.Count == 3)
            {
                // for "Includes" extension method - when 2nd argument lookupId is provided need to add LookupId attribute to field ref operand
                var lookupIdExpr = body.Arguments[2];
                if (lookupIdExpr is ConstantExpression && (bool)((ConstantExpression)lookupIdExpr).Value)
                {
                    valueOperand = new LookupIdValueOperand("0");
                }
            }

            return(operandBuilder.CreateFieldRefOperand(obj, valueOperand));
        }