コード例 #1
0
        private void VisitLinqExtensionsMethodCall(MethodCallExpression expression)
        {
            switch (expression.Method.Name)
            {
            case "Search":
                VisitExpression(expression.Arguments[0]);
                var    expressionInfo = GetMember(expression.Arguments[1]);
                object value;
                if (GetValueFromExpressionWithoutConversion(expression.Arguments[2], out value) == false)
                {
                    throw new InvalidOperationException("Could not extract value from " + expression);
                }
                luceneQuery.Search(expressionInfo.Path, (string)value);
                if (GetValueFromExpressionWithoutConversion(expression.Arguments[3], out value) == false)
                {
                    throw new InvalidOperationException("Could not extract value from " + expression);
                }
                luceneQuery.Boost((decimal)value);
                break;

            case "In":
                var memberInfo = GetMember(expression.Arguments[0]);
                var objects    = GetValueFromExpression(expression.Arguments[1], GetMemberType(memberInfo));
                luceneQuery.WhereIn(memberInfo.Path, ((IEnumerable)objects).Cast <object>());

                break;

            default:
            {
                throw new NotSupportedException("Method not supported: " + expression.Method.Name);
            }
            }
        }