예제 #1
0
        private Expression BindClientSideProjector(MethodCallExpression node)
        {
            var arguments = new List <Expression>();

            arguments.Add(Visit(node.Arguments[0]));

            // we need to make sure that the serialization info for the parameter
            // is the item serialization from the parent IBsonArraySerializer
            var fieldExpression = arguments[0] as IFieldExpression;

            if (fieldExpression != null)
            {
                var arraySerializer = fieldExpression.Serializer as IBsonArraySerializer;
                BsonSerializationInfo itemSerializationInfo;
                if (arraySerializer != null && arraySerializer.TryGetItemSerializationInfo(out itemSerializationInfo))
                {
                    var lambda = ExpressionHelper.GetLambda(node.Arguments[1]);
                    _bindingContext.AddExpressionMapping(
                        lambda.Parameters[0],
                        new FieldExpression(
                            fieldExpression.FieldName,
                            itemSerializationInfo.Serializer,
                            lambda.Parameters[0]));
                }
            }

            arguments.Add(Visit(node.Arguments[1]));

            if (node.Arguments[0] != arguments[0] || node.Arguments[1] != arguments[1])
            {
                node = Expression.Call(node.Method, arguments.ToArray());
            }

            return(node);
        }
예제 #2
0
        public static WhereExpression BindWhere(PipelineExpression pipeline, IBindingContext bindingContext, LambdaExpression lambda)
        {
            bindingContext.AddExpressionMapping(lambda.Parameters[0], pipeline.Projector);

            var predicate = bindingContext.Bind(lambda.Body);

            return(new WhereExpression(
                       pipeline.Source,
                       lambda.Parameters[0].Name,
                       predicate));
        }
예제 #3
0
        public static WhereExpression BindWhere(PipelineExpression pipeline, IBindingContext bindingContext, LambdaExpression lambda)
        {
            bindingContext.AddExpressionMapping(lambda.Parameters[0], pipeline.Projector);

            var predicate = bindingContext.Bind(lambda.Body);

            return new WhereExpression(
                pipeline.Source,
                lambda.Parameters[0].Name,
                predicate);
        }
예제 #4
0
        public static SelectExpression BindSelect(PipelineExpression pipeline, IBindingContext bindingContext, LambdaExpression lambda)
        {
            bindingContext.AddExpressionMapping(lambda.Parameters[0], pipeline.Projector);

            var selector = bindingContext.Bind(lambda.Body);

            return(new SelectExpression(
                       pipeline.Source,
                       lambda.Parameters[0].Name,
                       selector));
        }
예제 #5
0
        public static SelectExpression BindSelect(PipelineExpression pipeline, IBindingContext bindingContext, LambdaExpression lambda)
        {
            bindingContext.AddExpressionMapping(lambda.Parameters[0], pipeline.Projector);

            var selector = bindingContext.Bind(lambda.Body);

            return new SelectExpression(
                pipeline.Source,
                lambda.Parameters[0].Name,
                selector);
        }