Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4727

IFindFluent.Project on a single field always returns null

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: 2.19.1, 2.20.0
    • Component/s: None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            skohn@goflow.com Shiya Kohn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: