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

Change in behaviour of parsing nested .Any predicates

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Blocker - P1 Blocker - P1
    • 2.8.1
    • Affects Version/s: 2.8.0
    • Component/s: Linq
    • None
    • Major Change

      Hello

      I have 2 classes:

      public class Donation    

      {                public ObjectId Id \{ get; set; }
              public ICollection<Item> Items { get; set; }

      }

      public class Item    
      {                public ObjectId Id { get; set; }

              public ICollection<ObjectId> ParentIds { get; set; }

      }

      Example Data:

      {   

           "_id" : ObjectId("553682b4ecab640ee4ba35e5"),       

           "Items" : [        

                             

      {     "_id" : ObjectId("553682b4ecab640ee4ba35e6"),                              "ParentIds" : [                                                     ObjectId("55368285ecab640eb8d6976f"),                                     ObjectId("55368256ecab640eb8d6976e"),                                      ObjectId("55016c84b9e76f04a8821be5")                                          ]                              }

          ]}

       

      I have the following c# predicate:
      find(x => x.Items.Any(d => d.ParentIds.Any(p => p == ObjectId("55368256ecab640eb8d6976e"))))

       

      V2.7.3 behaviour emits:

      .find({ "Items.ParentIds" : ObjectId("55368256ecab640eb8d6976e") })

       

      V.2.8.0 behaviour emits:

      .find({ "Items.ParentIds" : { "$elemMatch" :

      { "" : ObjectId("55368256ecab640eb8d6976e") }

      } })

       

      This breaks our production build, working happily for several years now....

       

      Thanks

       

       

            Assignee:
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Reporter:
            kevin.fairs@neighbourly.com Kevin Fairs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: