示例#1
0
        protected override Expression VisitLambda <T>(Expression <T> node)
        {
            if (_parameter != null)
            {
                throw new NotSupportedException("Only one lambda expression is allowed in a subdocument path.");
            }

            _parameter = node.Parameters[0];

            // Simplify the body before processing.  This makes any external variable references constants, and also
            // reduces any expressions that can be simplified.
            var body = LambdaSimplifyingExpressionVisitor.Simplify(node.Body);

            body = Visit(body);

            if (!_parameterEncountered)
            {
                throw new NotSupportedException("The first statement in a subdocument path must be a reference to the lambda parameter.");
            }

            return(node.Update(body, node.Parameters));
        }