public Expression Bind(PipelineExpression pipeline, PipelineBindingContext bindingContext, MethodCallExpression node, IEnumerable <Expression> arguments) { var source = pipeline.Source; if (arguments.Any()) { source = BinderHelper.BindWhere( pipeline, bindingContext, ExpressionHelper.GetLambda(arguments.Single())); } var serializer = bindingContext.GetSerializer(node.Type, null); var accumulator = new AccumulatorExpression( node.Type, "__result", serializer, AccumulatorType.Sum, Expression.Constant(1)); source = new GroupByExpression( node.Type, source, Expression.Constant(1), new[] { accumulator }); return(new PipelineExpression( source, new FieldExpression(accumulator.FieldName, accumulator.Serializer), new CountResultOperator( node.Type, bindingContext.GetSerializer(node.Type, node)))); }
public Expression Bind(PipelineExpression pipeline, EmbeddedPipelineBindingContext bindingContext, MethodCallExpression node, IEnumerable <Expression> arguments) { var source = BinderHelper.BindWhere( pipeline, bindingContext, ExpressionHelper.GetLambda(arguments.Single())); return(new PipelineExpression( source, pipeline.Projector)); }
public Expression Bind(PipelineExpression pipeline, EmbeddedPipelineBindingContext bindingContext, MethodCallExpression node, IEnumerable <Expression> arguments) { var source = pipeline.Source; if (arguments.Any()) { source = BinderHelper.BindWhere( pipeline, bindingContext, ExpressionHelper.GetLambda(arguments.Single())); } return(new PipelineExpression( source, pipeline.Projector, new CountResultOperator(node.Type))); }
public Expression Bind(PipelineExpression pipeline, PipelineBindingContext bindingContext, MethodCallExpression node, IEnumerable <Expression> arguments) { var source = pipeline.Source; if (arguments.Any()) { source = BinderHelper.BindWhere( pipeline, bindingContext, ExpressionHelper.GetLambda(arguments.Single())); } source = new TakeExpression(source, Expression.Constant(1)); return(new PipelineExpression( source, pipeline.Projector, new AnyResultOperator())); }
public Expression Bind(PipelineExpression pipeline, EmbeddedPipelineBindingContext bindingContext, MethodCallExpression node, IEnumerable <Expression> arguments) { var source = pipeline.Source; if (arguments.Any()) { source = BinderHelper.BindWhere( pipeline, bindingContext, ExpressionHelper.GetLambda(arguments.Single())); } return(new PipelineExpression( source, pipeline.Projector, new FirstResultOperator( node.Type, pipeline.Projector.Serializer, node.Method.Name == nameof(Enumerable.FirstOrDefault)))); }