[CSHARP-2097] ProjectionDefinition.Expression does not create correct mongo statement Created: 16/Nov/17  Updated: 11/Feb/19  Resolved: 11/Feb/19

Status: Closed
Project: C# Driver
Component/s: Serialization
Affects Version/s: 2.4.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Vadim Rybak Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 10, .net standard 2 project


Issue Links:
Duplicate
duplicates CSHARP-2106 Projection fails when expression has ... Closed

 Description   

When you have a nested object where there are 2 properties such that the name of the first property starts with the name of the second property.
```
public class SubscriberSource
{
/// ...
public DateTime? StatusChangeDate

{ get; set; }
public SubscriberStatus Status { get; set; }

}
```
And you try to build a projection, it will not generate anything for the projection at all. There is probably somewhere in the code that a .startsWith is utilized to add fields to the projection builder for some reason.

So when i write something like
```
_collection.Find(query).Project(x => new

{ x.StatusChangeDate, x.Status }

)
```
No projection is passed to mongoDb at all and all fields are returned.


Generated at Wed Feb 07 21:41:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.