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

Incorrect $unwind query when using SelectMany in subobjects

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical - P2 Critical - P2
    • 2.8.0
    • 2.5
    • Linq
    • None

    Description

      For SelectMany in subobjects, driver generate wrong unwind query

      We have 2 objects:

      public class Mention
          {
              [BsonRepresentation(BsonType.ObjectId)]
              public string Id { get; set; }
             
              public RelatedData Related { get; set; }
          }
       
          public class RelatedData
          {
              public List<int> Players { get; set; }
              public List<int> Clubs { get; set; }
          }
      

      And we have query:

      _context.For<Mention>().AsQueryable()
                     .Where(...)
                     .SelectMany(x => x.Related.Players)
                     .ToList()
      

      For this query driver generate :

      {  "$match" : {  ....  }  },
      {  "$unwind" : "$Players" } <--- must be "$Related.Players"
      
      

      Attachments

        Activity

          People

            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            zoxexivo@gmail.com Ivan Artemov
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: