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

LINQ3 produces ExpressionNotSupported error on ContainsKey for DictionaryRepresentation.ArrayOfDocuments

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 2.20.0
    • Component/s: LINQ3
    • 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

      LINQ3 queries using ContainsKey on a Dictionary that is stored as DictionaryRepresentation.ArrayOfDocuments throws a ExpressionNotSupported exception.  ContainsKey support was added to dictionaries stored as DictionaryRepresentation.Document in CSHARP-4557 and this commit Support needed for the ArrayOfDocuments representation as well.

      How to Reproduce

      public class Model {
        [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfDocuments)]
        public virtual Dictionary<string, string> Foo { get; set; }
      }
      
      collection.AsQueryable()
        .Where(x => x.Foo.ContainsKey("x")).ToList();

      Additional Background

      The LINQ2 code for this I found here 

       

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            jgonyo@snagajob.com John Gonyo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: