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

Search doesn't work when embedded document stored with type

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Operations

    Description

      I have got 2 documents in a collection. Second document is updated once and so has got different representation of Platforms (with type and value). It gets serialized into C# object properly but when I search inside Platforms array using platform id, I get only one record back which is first document. I am using following C# code for the search:

      var filter = Builders<Application>.Filter.Eq("Platforms.Id", platform.Id);
      var documents = await _collection.Find(filter).ToListAsync();
      

      Document:

      {
        "_id" : ObjectId("5666aa08e592a021485b18b0"), 
        "Name" : "App1",
        "Platforms" : [{
            "_id" : "5665a0cde592942148a9ac2f",
            "Name" : "Windows"
          }, {
            "_id" : "5665a0d3e592942148a9ac30",
            "Name" : "iOS"
          }]
      }
       
      {
        "_id" : ObjectId("5666aa19e592a021485b18b1"),  
        "Name" : "App2",
        "Platforms" : {
          "_t" : "System.Collections.Generic.List`1[[MyPortal.Model.DTO.Lookup, MyPortal.Model]]",
          "_v" : [{
              "_id" : "5665a0d3e592942148a9ac30",
              "Name" : "iOS"
            }, {
              "_id" : "5665a0cde592942148a9ac2f",
              "Name" : "Windows x"
            }]
        }  
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            alpesh12212 Alpesh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: