Hi ,
After upgrading Mongodb C# driver to version 2.25.0, some of my queries are break and throw exception when using ElemMatch. It works fine in version < 2.18.0.
My class look likes :
[MongoCollection(ObjectType = "Item")]
[BsonIgnoreExtraElements]
public class Item
{
public IEnumerable<string> RelativeItemIds { get; set; }
}
and my old query look like :
var builder = Builders<Item>.Filter;
var listRefIds = new List<string>{refId};
var filter = builder.ElemMatch(t => t.RelativeItemIds , t => listRefIds .Contains(t));
var data = await Collection.Find(filter).ToListAsync();
The exception is :
unable to cast object of type 'MongoDB.Bson.Serialization.Serializers.StringSerializer' to type 'MongoDB.Bson.Serialization.IBsonDocumentSerializer
Could someone please help me to resolve it?