protected internal virtual Expression VisitDocument(DocumentExpression node)
 {
     return(node);
 }
 protected internal virtual Expression VisitDocument(DocumentExpression node)
 {
     return node;
 }
Exemplo n.º 3
0
 private bool CompareDocument(DocumentExpression a, DocumentExpression b)
 {
     // not exact...
     return(a.Serializer.GetType() == b.Serializer.GetType());
 }
Exemplo n.º 4
0
 protected internal override Expression VisitDocument(DocumentExpression node)
 {
     return new FieldExpression(
         _prefix,
         node.Serializer);
 }
        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;
        }