-
Type: Bug
-
Resolution: Duplicate
-
Priority: Critical - P2
-
None
-
Affects Version/s: 2.19.1, 2.20.0
-
Component/s: None
-
None
Summary
When using IMongoCollection<T>` to do a find and project a property from a document, the resulting data will be null,
Versions
As far as I can tell, this starts in 2.19.x, this affects the Linq V3 adapter only.
How to Reproduce
Start by defining a schema, example:
class Point {
public int X { get; set; }
^ ^public int Y { get; set; }
}
Then create an IMongoCollection<Point>(omitting this for brevity), the following code is where things start getting weird.
If I do a simple .Find(...).ToList(), the results will be properly serialized into points exactly as I entered them, however, try to project just X or just Y, and you'll get the default values (0 in this case).
Example code
collection.Find(point => point.X == 90).Project(point => point.X).ToList()
Regardless of your data, this will return a list of 0s. The underlying query is correctly formatted into something like "find({ "X" : 90 }, { "_v" : "$X", "_id" : 0 })", however, the results are missing the actual X points.
- duplicates
-
CSHARP-4666 Support projecting a single field with Find on servers prior to 4.4
- Closed