Search doesn't work when embedded document stored with type

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Operations
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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"
            }]
        }  
      }
      

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

              Created:
              Updated:
              Resolved: