File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
src/MongoDB.Driver/Linq/Processors/Pipeline
tests/MongoDB.Driver.Tests/Linq Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,8 @@ public SerializationExpression BindProjector(ref Expression selector)
100100 var projector = selector as SerializationExpression ;
101101 if ( selector . NodeType == ExpressionType . MemberInit || selector . NodeType == ExpressionType . New )
102102 {
103- var serializer = GetSerializer ( selector . Type , selector ) ;
103+ var serializer = SerializerBuilder . Build ( selector , _serializerRegistry ) ;
104+
104105 projector = new DocumentExpression ( serializer ) ;
105106 }
106107 else if ( projector == null || projector is PipelineExpression || projector is IFieldExpression || projector is ArrayIndexExpression )
Original file line number Diff line number Diff line change @@ -884,6 +884,16 @@ public void Select_identity()
884884 Assert ( query , 2 ) ;
885885 }
886886
887+ [ Fact ]
888+ public void Select_new_of_same ( )
889+ {
890+ var query = CreateQuery ( ) . Select ( x => new Root { Id = x . Id , A = x . A } ) ;
891+
892+ Assert ( query ,
893+ 2 ,
894+ "{ $project: { Id: '$_id', A: '$A', _id: 0} }" ) ;
895+ }
896+
887897 [ Fact ]
888898 public void Select_method_computed_scalar_followed_by_distinct_followed_by_where ( )
889899 {
You can’t perform that action at this time.
0 commit comments