public Expression Bind(ProjectionExpression projection, ProjectionBindingContext context, MethodCallExpression node, IEnumerable<Expression> arguments)
        {
            var distinct = new DistinctExpression(projection.Source, projection.Projector);

            var serializer = SerializerBuilder.Build(projection.Projector, context.SerializerRegistry);
            var info = new BsonSerializationInfo("_id", serializer, serializer.ValueType);
            var projector = new SerializationExpression(projection.Projector, info);

            return new ProjectionExpression(
                distinct,
                projector);
        }
 protected internal virtual Expression VisitDistinct(DistinctExpression node)
 {
     return(node.Update(Visit(node.Source)));
 }
 protected internal virtual Expression VisitDistinct(DistinctExpression node)
 {
     return node.Update(Visit(node.Source));
 }
        private void VisitDistinct(DistinctExpression node)
        {
            Visit(node.Source);

            var id = new BsonDocument("_id", AggregateLanguageTranslator.Translate(node.Selector));
            _stages.Add(new BsonDocument("$group", id));
        }