LINQ projection with conditional null check and FirstOrDefault on nested array fails

XMLWordPrintableJSON

    • 🔵 Done
    • Dotnet Drivers
    • 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?
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      LINQ3 projection fails when using a conditional null check followed by Select().FirstOrDefault() on a nested array property. The workaround using the null-coalescing operator (??) or using .First() works correctly.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      MongoDB 8.2.1 Community 

      Driver Version 3.5

       

            Assignee:
            Robert Stam
            Reporter:
            Janis Zinn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: