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

IReadOnlyDictionary indexer access fails to translate in v3

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • 2.28.0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • Dotnet Drivers
    • 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?

      The following query will work when the property is IDictionary in V2 & V3 and will also work with IReadOnlyDictionary in V2:

      var results = queryable.Where(q => q.dict["This"] = "That").ToList();

      But the combination of dict being IReadOnlyDictionary and running with LINQ V3 fails with the exception message:

       Expression not supported: q.dict.get_Item("This").

      The queryable class definition being:

      class A {
        public ObjectId _id { get; set;
        public IReadOnlyDictionary dict { get; set; }
      }
      

      This is causing some issues in the EF provider support for IReadOnlyDictionary.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            damien.guard@mongodb.com Damien Guard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: