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

LINQ3 produces ExpressionNotSupported error on ContainsKey

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.19.1
    • Affects Version/s: 2.19.0
    • Component/s: LINQ3
    • Not Needed
    • 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

      After upgrading from version 2.18.0 to 2.19.0, I encountered this error in my project:

      {{MongoDB.Driver.Linq.ExpressionNotSupportedException: Expression not supported: x.Foo.ContainsKey("bar")
      }}
      After explicitly setting the LinqProvider back to V2, the error disappears.

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

      Driver version: 2.19.0

      Server version: 5.0.15

      How to Reproduce

      For a collection of documents in this format:

      {{{}}
          _id: ...,
          Foo:

      {         "bar": 100,         "baz": 200     }

      }
      Create an IQueryable and perform the following LINQ query:
      entities.Where(x => x.Foo.ContainsKey("bar"));

      Additional Background

      I'm not sure what else would be useful to add here, but I'm happy to provide further details if required.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            chris.dueck@avcosystems.com Chris Dueck
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: