Example #1
0
        public TResult Execute <TResult>(Expression expression)
        {
            var itemType = TypeHelper.GetElementType(expression.Type);

            var translator  = new ExpressionToFTSRequestTranslator();
            var queryString = translator.Translate(expression);

            return((TResult)(e3sClient.SearchFTS(itemType, queryString)));
        }
Example #2
0
        protected override Expression VisitBinary(BinaryExpression node)
        {
            Expression nodeLeft  = node.Left;
            Expression nodeRight = node.Right;

            switch (node.NodeType)
            {
            case ExpressionType.Equal:



                if (nodeLeft.NodeType != ExpressionType.MemberAccess)
                {
                    nodeLeft  = node.Right;
                    nodeRight = node.Left;
                }

                if (nodeLeft.NodeType != ExpressionType.MemberAccess)
                {
                    throw new NotSupportedException(string.Format("Left operand should be property or field", node.NodeType));
                }

                if (nodeRight.NodeType != ExpressionType.Constant)
                {
                    throw new NotSupportedException(string.Format("Right operand should be constant", node.NodeType));
                }

                Visit(nodeLeft);
                resultString.Append("(");
                Visit(nodeRight);
                resultString.Append(")");
                break;

            case ExpressionType.And:
            case ExpressionType.AndAlso:
                var leftTranslator = new ExpressionToFTSRequestTranslator();
                var leftResult     = leftTranslator.TranslateAnd(nodeLeft);
                queries.AddRange(leftResult);

                var rightTranslator = new ExpressionToFTSRequestTranslator();
                var rightResult     = rightTranslator.TranslateAnd(nodeRight);
                queries.AddRange(rightResult);

                break;

            default:
                throw new NotSupportedException(string.Format("Operation {0} is not supported", node.NodeType));
            }
            return(node);
        }