protected internal override Expression VisitDocumentWrappedField(FieldAsDocumentExpression node) { var field = Visit(node.Document) as IFieldExpression; if (field != null) { return new FieldExpression( node.PrependFieldName(field.FieldName), node.Serializer); } return node; }
protected internal virtual Expression VisitDocumentWrappedField(FieldAsDocumentExpression node) { return(node.Update( Visit(node.Expression))); }
protected internal virtual Expression VisitDocumentWrappedField(FieldAsDocumentExpression node) { return node.Update( Visit(node.Expression)); }
private BsonValue TranslateDocumentWrappedField(FieldAsDocumentExpression expression) { return new BsonDocument(expression.FieldName, TranslateValue(expression.Expression)); }
private bool CompareDocumentWrappedField(FieldAsDocumentExpression a, FieldAsDocumentExpression b) { return(a.FieldName == b.FieldName && Compare(a.Expression, b.Expression)); }
public SerializationExpression BindProjector(ref Expression selector) { var projector = selector as SerializationExpression; if (selector.NodeType == ExpressionType.MemberInit || selector.NodeType == ExpressionType.New) { var serializer = GetSerializer(selector.Type, selector); projector = new DocumentExpression(serializer); } else if (projector == null || projector is IFieldExpression || projector is ArrayIndexExpression) { var newFieldName = "__fld0"; if (projector is IFieldExpression) { // We don't have to do this, but it makes the output a little nicer. newFieldName = ((IFieldExpression)projector).FieldName; } // the output of a $project stage must be a document, so // if this isn't already a serialization expression and it's not // a new expression or member init, then we need to create an // artificial field to project the computation into. var serializer = GetSerializer(selector.Type, selector); selector = new FieldAsDocumentExpression(selector, newFieldName, serializer); projector = new FieldExpression(newFieldName, serializer); } return projector; }