protected static Expression BindPredicate(ProjectionExpression projection, ProjectionBindingContext context, Expression source, Expression argument) { // this is actually a predicate that needs to be rendered as a WhereExpression var lambda = ExtensionExpressionVisitor.GetLambda(argument); var binder = new AccumulatorBinder(context.GroupMap, context.SerializerRegistry); binder.RegisterParameterReplacement(lambda.Parameters[0], projection.Projector); var predicate = binder.Bind(lambda.Body); source = new WhereExpression( source, predicate); return source; }
protected internal override Expression VisitWhere(WhereExpression node) { var sourceWhere = node.Source as WhereExpression; if (sourceWhere != null) { var source = sourceWhere.Source; var newWhere = new WhereExpression( source, node.ItemName, Expression.And( sourceWhere.Predicate, node.Predicate)); return base.Visit(newWhere); } return node; }
protected internal virtual Expression VisitWhere(WhereExpression node) { return(node.Update( Visit(node.Source), Visit(node.Predicate))); }
private void TranslateWhere(WhereExpression node) { Translate(node.Source); var predicateValue = PredicateTranslator.Translate(node.Predicate, _serializerRegistry); _stages.Add(new BsonDocument("$match", predicateValue)); }
protected internal virtual Expression VisitWhere(WhereExpression node) { return node.Update( Visit(node.Source), Visit(node.Predicate)); }
private BsonValue TranslateWhere(WhereExpression node) { var inputValue = TranslateValue(node.Source); var condValue = TranslateValue(FieldNamePrefixer.Prefix(node.Predicate, "$" + node.ItemName)); return new BsonDocument("$filter", new BsonDocument { { "input", inputValue }, { "as", node.ItemName }, { "cond", condValue } }); }
private void VisitWhere(WhereExpression node) { Visit(node.Source); var renderedPredicate = PredicateTranslator.Translate(node.Predicate, _serializerRegistry); _stages.Add(new BsonDocument("$match", renderedPredicate)); }